Project

General

Profile

Task #7638

Updated by Rob Nahf almost 9 years ago

RestClient holds a key-value map of headers to add to Request objects. It is inherently thread unsafe, since the RestClient instance is likely to be shared between threads. A keyword scan of CN projects shows that it is not in use, so there is little impact.

Add the @Deprecated annotation to the applicable methods, and a javadoc @deprecated comment.

For users that want more control over the HTTP requests, they should instead build an HttpRequestInterceptor and add it to the ConnectionManager at HttpClient at build time, like so:
<pre>
HttpClientBuilder builder = org.dataone.client.utils.HttpUtils.getHttpClientBuilder(certificateOrTokenMaterial);
builder.addInterceptorLast(new

org.dataone.client.utils.HttpUtils.getHttpClientBuilder(certificateOrTokenMaterial)
.addInterceptorLast(new
HttpRequestInterceptor() {

@Override
public void process(final HttpRequest request, final HttpContext context)
throws HttpException, IOException
{
// custom header additions here

request.addHeader(key, value);
}
});
</pre>

Back

Add picture from clipboard (Maximum size: 14.8 MB)