jclouds-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Gaul <g...@apache.org>
Subject Re: HTTP Headers
Date Fri, 11 Nov 2016 01:19:20 GMT
jclouds does not allow arbitrary HTTP headers; we generally provide a
mechanism to set any vendor-specific header in the provider
implementation.  Specifically for User-Agent, we have an open feature
request:

https://issues.apache.org/jira/browse/JCLOUDS-819

This is a well-scoped task and we would appreciate a pull request to
include it.  Would you be willing to address this?

On Thu, Nov 10, 2016 at 09:27:45PM +0000, Paya, Ashkan wrote:
> Hello,
> 
> Can we use/overwrite HTTP headers such as USER_AGENT when invoking methods like BlobStore.putBlob()
or we need to specify the BlobRequestSigner and use HttpClient instead?
> For example, if I want to include the HTTP headers in the following operation:
> 
> 
> ByteSource input = ByteSource.wrap(“BLAH”.getBytes(StandardCharsets.UTF_8));
> 
>  Blob blob = blobStore
> 
> 
>     .blobBuilder(“NAME")
> 
> 
>     .payload(input)
> 
> 
>     .contentLength(input.size())
> 
> 
>     .contentMD5(input.hash(Hashing.md5()))
> 
> 
>     .contentType("text/plain")
> 
> 
>     .build();
> 
> 
>  blobStore.putBlob(container, blob);
> 
> 
> Should I use the BlobRequestSigner as follows? Is this the right approach?
> 
> 
>  final BlobRequestSigner signer = blobStoreInfo.getBlobRequestSigner();
> 
> 
>  HttpRequest request = signer.signPutBlob(container, blob)
> 
> 
>     .toBuilder()
> 
> 
>     .addHeader(HttpHeaders.CONTENT_LENGTH,
> 
> 
>         String.valueOf(input.size()))
> 
> 
>     .addHeader(HttpHeaders.USER_AGENT, “custom agent")
> 
> 
>     .payload(input)
> 
> 
>     .build();
> 
> 
>  HttpClient httpClient = blobStore.getContext().utils().http());
> 
> httpClient.invoke(request);
> 
> 
> 
> 
> 
> Thank you,
> Ashkan

-- 
Andrew Gaul
http://gaul.org/

Mime
View raw message