When a web server returns a JPEG image (mime type image/jpeg), how is that encoded?

后端 未结 3 1248
死守一世寂寞
死守一世寂寞 2021-01-04 20:47

If you make an HTTP request to a web server, and it returns a response of type image/jpeg, how is the binary data actually encoded? Is it the original byte-level content of

3条回答
  •  悲哀的现实
    2021-01-04 21:05

    The encoded transfered data is specified by the Content-Encoding HTTP response header (see HTTP 1.1 specifications in RFC2616 section 14.11 and 3.5). If present, it can be either gzip, compress, or deflate compressed data (no others are defined in HTTP 1.1). If not, the data is in original encoding based on the Content-Type HTTP response header (the MIME type). The Content-Encoding is determined by the Accept-Encoding HTTP request header value and whether the web server support requested encoding.

    In your case, if the Content-Encoding HTTP response header is absent, the data is exactly the same as the file contents. Otherwise, it's compressed with the specified encoding. e.g.: GZip or Deflate.

提交回复
热议问题