[
https://issues.apache.org/jira/browse/JCLOUDS-578?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrew Gaul updated JCLOUDS-578:
--------------------------------
Description:
Rackspace allows users to set custom HTTP Headers on their files that are being
served. This is especially useful for web fonts, as some browsers refuse to use
the fonts unless the following header is set (more info
[here|http://davidwalsh.name/cdn-fonts]):
{{Access-Control-Allow-Origin: *}}
Upon getting a SwiftObject from my Rackspace CloudFilesClient object and
calling {{getAllHeaders().put( "Access-Control-Allow-Origin", "*" )}} I could
see that the header was being lost and not sent with the underlying HTTP
request.
As a workaround here I patched
[{{org.jclouds.openstack.swift.binders.BindSwiftObjectMetadataToRequest}}|https://github.com/jclouds/jclouds/blob/master/apis/swift/src/main/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequest.java].
Instead of simply binding the blob to the request and returning it (lines 86 +
87), I changed it to bind the blob, then added all headers from the blob to the
request.
{{noformat}}
Blob blob = object2Blob.apply( object );
request = mdBinder.bindToRequest( request, blob );
return ( R ) request.toBuilder().replaceHeaders( blob.getAllHeaders() ).build();
{{noformat}}
was:
Rackspace allows users to set custom HTTP Headers on their files that are being
served. This is especially useful for web fonts, as some browsers refuse to use
the fonts unless the following header is set (more info
[here|http://davidwalsh.name/cdn-fonts]):
{{Access-Control-Allow-Origin: *}}
Upon getting a SwiftObject from my Rackspace CloudFilesClient object and
calling {{getAllHeaders().put( "Access-Control-Allow-Origin", "*" )}} I could
see that the header was being lost and not sent with the underlying HTTP
request.
As a workaround here I patched
[{{org.jclouds.openstack.swift.binders.BindSwiftObjectMetadataToRequest}}|https://github.com/jclouds/jclouds/blob/master/apis/swift/src/main/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequest.java].
Instead of simply binding the blob to the request and returning it (lines 86 +
87), I changed it to bind the blob, then added all headers from the blob to the
request.
{{Blob blob = object2Blob.apply( object );}}
{{request = mdBinder.bindToRequest( request, blob );}}
{{return ( R ) request.toBuilder().replaceHeaders( blob.getAllHeaders()
).build();}}
> Custom HTTP Headers in Rackspace SwiftObjects are ignored
> ----------------------------------------------------------
>
> Key: JCLOUDS-578
> URL: https://issues.apache.org/jira/browse/JCLOUDS-578
> Project: jclouds
> Issue Type: Bug
> Components: jclouds-blobstore
> Affects Versions: 1.7.1
> Reporter: Daren Klamer
> Priority: Minor
> Labels: rackspace
>
> Rackspace allows users to set custom HTTP Headers on their files that are
> being served. This is especially useful for web fonts, as some browsers
> refuse to use the fonts unless the following header is set (more info
> [here|http://davidwalsh.name/cdn-fonts]):
> {{Access-Control-Allow-Origin: *}}
> Upon getting a SwiftObject from my Rackspace CloudFilesClient object and
> calling {{getAllHeaders().put( "Access-Control-Allow-Origin", "*" )}} I could
> see that the header was being lost and not sent with the underlying HTTP
> request.
> As a workaround here I patched
> [{{org.jclouds.openstack.swift.binders.BindSwiftObjectMetadataToRequest}}|https://github.com/jclouds/jclouds/blob/master/apis/swift/src/main/java/org/jclouds/openstack/swift/binders/BindSwiftObjectMetadataToRequest.java].
> Instead of simply binding the blob to the request and returning it (lines 86
> + 87), I changed it to bind the blob, then added all headers from the blob to
> the request.
> {{noformat}}
> Blob blob = object2Blob.apply( object );
> request = mdBinder.bindToRequest( request, blob );
> return ( R ) request.toBuilder().replaceHeaders( blob.getAllHeaders()
> ).build();
> {{noformat}}
--
This message was sent by Atlassian JIRA
(v6.2#6252)