You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by "Andrew Gaul (JIRA)" <ji...@apache.org> on 2014/05/30 04:34:01 UTC
[jira] [Commented] (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:comment-tabpanel&focusedCommentId=14013224#comment-14013224 ]
Andrew Gaul commented on JCLOUDS-578:
-------------------------------------
I believe we should add another setter and getter for CORS to {{MutableObjectInfoWithMetadata}} then swizzle it to {{Access-Control-Allow-Origin}} in {{BindSwiftObjectMetadataToRequest}} as we do for {{ETag}} and {{X-Delete-At}}. Generally jclouds does not allow setting headers other than the user metadata.
> 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.
> {{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)