You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by "Daren Klamer (JIRA)" <ji...@apache.org> on 2014/05/30 04:09:01 UTC
[jira] [Updated] (JCLOUDS-578) Custom HTTP Headers in Rackspace
SwiftObjects are ignored
[ https://issues.apache.org/jira/browse/JCLOUDS-578?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daren Klamer 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:
{{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 at the end, 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();}}
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:
{{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}}. Instead of simply binding the blob to the request at the end, 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:
> {{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 at the end, 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();}}
--
This message was sent by Atlassian JIRA
(v6.2#6252)