An HTTP header of an object is a string sent by the server over HTTP before it sends HTML data to the browser. By modifying HTTP headers, you can modify how the webpage responds as well as certain configurations, such as caching time. Modifying an object's HTTP headers does not modify the object itself.
For example, if the Content-Encoding
header is modified to gzip
, but the file itself was not compressed using gzip, a decoding error will occur.
Note:
Note that custom headers are not supported for archived objects.
HTTP Header | Description | Example |
---|---|---|
Content-Type | MIME information of the file | image/jpeg |
Cache-Control | File caching mechanism | no-cache;max-age=200 |
Content-Disposition | MIME type extension | attachment;filename="fname.ext" |
Content-Encoding | File encoding format | UTF-8 |
Expires | Controls the expiration date of cache | Wed, 21 Oct 2015 07:28:00 GMT |
x-cos-meta-[custom suffix] | User-defined header | x-cos-meta-via: homepage |
Assume that a bucket named "examplebucket-1250000000" was created under account APPID 1250000000, and an object “exampleobject.txt” was uploaded to the bucket’s root directory.
The sample below shows the headers returned for a request to download this object through a browser or client if no custom HTTP headers are specified.
GET /exampleobject.txt HTTP/1.1
Host: examplebucket-1250000000.file.myqcloud.com
Accept: */*
HTTP/1.1 200 OK
Content-Language:zh-CN
Content-Type: text/plain
Content-Disposition: attachment; filename*="UTF-8''exampleobject.txt"
Access-Control-Allow-Origin: *
Last-Modified: Tue, 11 Jul 2017 15:30:35 GMT
If you add custom headers as follows:
then the headers returned for new requests will be as follows:
GET /exampleobject.txt HTTP/1.1
Host: examplebucket-1250000000.file.myqcloud.com
Accept: */*
HTTP/1.1 200 OK
Content-Language:zh-CN
Cache-Control: no-cache
Content-Type: image/jpeg
Content-Disposition: attachment; filename*="abc.txt"
x-cos-meta-md5: 1234
Access-Control-Allow-Origin: *
Last-Modified: Tue, 11 Jul 2017 15:30:35 GMT
Was this page helpful?