Common request headers

Updated at:
Copy as MD

All Simple Log Service API requests support a set of common HTTP headers for authentication, compression, and content negotiation.

Parameters

The following table lists the common request headers for SLS RESTful APIs.
Header name Type Required Description
Accept String No Expected response format. Valid values: application/json, application/x-protobuf. Applies to GET requests only. The accepted value varies by API.
Accept-Encoding String No Expected response compression. Valid values: lz4, deflate, or empty (no compression). Applies to GET requests only. The accepted value varies by API.
Authorization String Yes The request signature string calculated per Request signatures.
Content-Length Number No The HTTP request body length (RFC 2616). Not required if the request has no body.
Content-MD5 String No Uppercase MD5 hash of the request body. Not required if the request has no body.
Content-Type String No The HTTP request body type (RFC 2616). Currently only application/x-protobuf is supported. Not required if the request has no body. The accepted value varies by API.
Date String Yes Request timestamp in GMT, RFC 1123 format. Example: Mon, 3 Jan 2010 08:33:47 GMT.
Host String Yes Full host name of the endpoint, without the protocol prefix (such as http://). Example: big-game.cn-hangzhou.sls.aliyuncs.com.
x-log-apiversion String Yes The API version. The current version is 0.6.0.
x-log-bodyrawsize Number No Raw (uncompressed) request body size in bytes. Set to 0 if the request has no body. For compressed requests, specify the pre-compression size. Valid range: 0–3,145,728. Required only when the body is compressed.
x-log-compresstype String No Request body compression algorithm. Valid values: lz4, deflate (RFC 1951, zlib format per RFC 1950). Omit this header if the body is not compressed.
x-log-date String No Request timestamp in the same format as Date. When present, overrides the Date header for server-side time validation but is not used in signature calculation. The standard Date header remains required even if x-log-date is specified.
x-log-signaturemethod String Yes The signature algorithm. The only supported value is hmac-sha1.
x-acs-security-token String No Required only when using STS temporary credentials to send data.
Note
  • The Date header value must be within 15 minutes of the server time, otherwise the request is rejected. When the x-log-date header is present, the time-skew check uses the x-log-date value instead of Date.
  • When x-log-compresstype is set, the request body must contain compressed data. Calculate Content-Length and Content-MD5 from the compressed body.
  • If your platform or HTTP library auto-sets the Date header, use x-log-date to supply the correct timestamp for signature calculation. The server validates the signature against x-log-date when present, or the standard Date header otherwise.

Example

POST / HTTP/1.1
Authorization: LOG <yourAccessKeyId>:<yourSignature>
x-log-bodyrawsize: 0
User-Agent: sls-java-sdk-v-0.6.1
x-log-apiversion: 0.6.0
Host: my-project-test.cn-shanghai.log.aliyuncs.com
x-log-signaturemethod: hmac-sha1
Date: Sun, 27 May 2018 07:43:26 GMT
Content-Type: application/json
Content-MD5: A7967D81EFF5E3CD447FB6D8DF294E20
Content-Length: 80
Connection: Keep-Alive