|
Discussion Forums
|
Thread: Additional HTTP headers?
 |
This question is not answered.
Helpful answers available: 2.
Correct answers available: 1.
|
|
|
|
Replies:
13
-
Pages:
1
-
Last Post:
Sep 1, 2009 2:55 PM
by: brianjlowry
|
|
|
Posts:
11
Registered:
3/8/07
|
|
|
|
Additional HTTP headers?
Posted:
May 23, 2007 5:23 PM PDT
|
|
|
I was under the impression that adding standard HTTP headers via the metadata would return them the same way, but it seems that only applied to Content-Type and not, for example, to Cache-Control or Expires... Is there a way to upload a file with these properties and have S3 return them when needed? I'm trying to force perm cache on the browser of resources that never change.
Thanks!
$ curl -I
https://s3.amazonaws.com/mybucket/version123/file.css HTTP/1.1 200 OK
x-amz-id-2: ICw8QYHXY0U4fD4dSciPf+EBRypDHSYugAJKR23SVIJnlnA7nsVqvvm44G/6vYam
x-amz-request-id: 6A682475E5AA19C8
Date: Thu, 24 May 2007 00:13:07 GMT
x-amz-meta-cache-control: max-age=315360000
x-amz-meta-content-type: text/css
x-amz-meta-date: Wed, 23 May 2007 00:00:23 GMT
x-amz-meta-expires: Sat, 20 May 2017 00:00:20 GMT
Last-Modified: Thu, 24 May 2007 00:12:18 GMT
ETag: "473022f2f5cd5414f46184733b2ec1fc"
Content-Type: text/css
Content-Length: 12197
Server: AmazonS3
|
|
Posts:
2,027
Registered:
3/15/06
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 23, 2007 6:01 PM PDT
in response to: deepcovelabs
|
|
|
The docs say that the following headers can be specified (at least via REST) when PUT'ing an object:
Cache-Control
Content-Type
Content-Length
Content-MD5
Content-Disposition
Content-Encoding
Expires
and then any other metadata you want to supply by prefixing it with the string "x-amz-meta-". So, I think you should be able to set a Cache-Control header on a PUT and have it returned with a GET. The fact that yours are coming out prefixed with the "x-amz-meta-" string makes me think that your client code is not sending the headers properly.
Mitch
|
|
Posts:
2,027
Registered:
3/15/06
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 23, 2007 6:05 PM PDT
in response to: M. Garnaat
|
|
|
Just to follow up, I tried a quick test with my boto library and I was able to set a Cache-Control header and have it returned on a GET request. I would check your client libraries.
Mitch
|
|
Posts:
11
Registered:
3/8/07
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 24, 2007 9:00 AM PDT
in response to: M. Garnaat
|
|
|
Hmm, okay, will do. Reason I didn't dig deeper was that content-type was set okay and the rest are done exactly the same way, but I ought to double check. Thanks!
|
|
Posts:
11
Registered:
3/8/07
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 24, 2007 9:16 AM PDT
in response to: deepcovelabs
|
|
|
Nope, not so much. Is it only supported by REST API and not SOAP? If so, any way to work around it? What's the point of having two APIs if one doesn't match the other?
Is there a way to, perhaps, add metadata with REST API after PUTing the object with SOAP API? Any hints would be greatly appreciated,
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="
http://s3.amazonaws.com/doc/2006-03-01/" xmlns:ns0="
http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns:PutObjectInline>
<ns:Bucket>mybucket</ns:Bucket>
<ns:Key>myfile.css</ns:Key>
<ns:Metadata>
<ns:Name>Content-Type</ns:Name>
<ns:Value>text/css</ns:Value>
</ns:Metadata>
<ns:Metadata>
<ns:Name>Cache-Control</ns:Name>
<ns:Value>max-age=315360000</ns:Value>
</ns:Metadata>
<ns:Metadata>
<ns:Name>Expires</ns:Name>
<ns:Value>Sun, 21 May 2017 00:00:21 GMT</ns:Value>
</ns:Metadata>
<ns:Metadata>
<ns:Name>Date</ns:Name>
<ns:Value>Thu, 24 May 2007 00:00:24 GMT</ns:Value>
</ns:Metadata>
<ns:Data>DATA WAS HERE</ns:Data>
<ns:ContentLength>532</ns:ContentLength>
<ns:AccessControlList>
<ns:Grant>
<ns:Grantee ns0:type="Group">
<ns:URI>
http://acs.amazonaws.com/groups/global/AllUsers</ns:URI>
</ns:Grantee>
<ns:Permission>READ</ns:Permission>
</ns:Grant>
</ns:AccessControlList>
<ns:AWSAccessKeyId>ACCESS KEY</ns:AWSAccessKeyId>
<ns:Timestamp>2007-05-24T16:10:58.000Z</ns:Timestamp>
<ns:Signature>SIGNATURE</ns:Signature>
</ns:PutObjectInline>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
|
|
Posts:
11
Registered:
3/8/07
|
|
|
Posts:
2,027
Registered:
3/15/06
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 24, 2007 10:07 AM PDT
in response to: deepcovelabs
|
|
|
That's not really possible. The entire PUT operation (content and metadata) is an atomic operation. You can't update metadata without re-writing all of the content.
Mitch
|
|
Posts:
11
Registered:
3/8/07
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 24, 2007 10:13 AM PDT
in response to: M. Garnaat
|
|
|
That's fair enough, although the better fix would be to treat metadata exactly the same way in SOAP as it is currently handled in REST. At the moment the prospect of changing from SOAP to REST just to be able to set those headers is slightly unnerving to me. Amazon, anyone listening? Can we at least agree its a bug with SOAP API or am I doing something wrong (completely possible, hence my including the full body of a typical inline PUT I use to upload objects)?
Thanks!
|
|
Posts:
2,027
Registered:
3/15/06
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 25, 2007 5:30 AM PDT
in response to: deepcovelabs
|
|
|
I think there should be parity across the different flavors of the API.
It certainly seems like a bug to me. Do you know if this is a problem in the API itself or in the client library? I've never used the SOAP interface so I just don't know.
Mitch
|
|
Posts:
11
Registered:
3/8/07
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 25, 2007 9:09 AM PDT
in response to: M. Garnaat
|
|
|
I'm pretty certain its not the library as the XML output seems to make sense to me and matches what documentation examples look like, so this is either a bug or a limitation of the API. If its the former, I'd like it fixed, if its the latter, I'd like it changed
Otherwise, what's the point of even having the second API if you can only do certain things, but not others.
|
|
Posts:
11
Registered:
3/8/07
|
|
|
|
Re: Additional HTTP headers?
Posted:
May 28, 2007 2:29 PM PDT
in response to: deepcovelabs
|
|
|
Is this it? Should I be looking to use REST instead of SOAP? If so, could we add a fat disclaimer to the docs that says setting meta http headers via SOAP is not supported?
|
|
Posts:
11
Registered:
3/8/07
|
|
|
|
Re: Additional HTTP headers?
Posted:
Jun 4, 2007 2:04 PM PDT
in response to: deepcovelabs
|
|
|
Oh well, I just changed our PUT API from SOAP to REST last week and was then able to set these headers properly. Still wouldn't mind some acknowledgement from Amazon whether they are planning on fixing SOAP equivalent any time soon.
|
|
Posts:
1
Registered:
4/21/08
|
|
|
|
Re: Additional HTTP headers?
Posted:
Nov 25, 2008 1:26 PM PST
in response to: M. Garnaat
|
|
|
I'm using boto library, but I I get the same problem as the other guy.
Amazon prefixes everything with 'x-amz-meta', I tried setting the metadata like this: ("x-amz-meta-Expires","Thu, 15 Apr 2010 20:00:00 GMT")
but what I get is this response header...
"x-amz-meta-x-amz-meta-Expires" = "Thu, 15 Apr 2010 20:00:00 GMT"
Message was edited by: darkskyzero
|
|
Posts:
3
Registered:
9/1/09
|
|
|
|
Re: Additional HTTP headers?
Posted:
Sep 1, 2009 2:55 PM PDT
in response to: deepcovelabs
|
|
|
Is there an update on this? Why can't we use the SOAP API to set Cache-Control and other relevant headers?
|
|
|
|