Skip to the content.

HTTP Basic

HTTP = HyperText Transfer Protocol

Syntax

<start-line>\r\n
<headers>\r\n
\r\n
<body>

See RFC 2616 - Hypertext Transfer Protocol – HTTP/1.1 (1999) (Obsoleted by RFC 9112 - HTTP/1.1 (2022.6)).

Request

<method> <url-path> <version>\r\n
<headers>\r\n
\r\n
<body>

for example:

GET / HTTP/1.1
HOST: www.example.com
Accept: */*

hello world

Response

<version> <status-code> <reason-phrase>\r\n
<headers>\r\n
\r\n
<body>

for example:

HTTP/1.1 200 OK
Date: Sun, 17 Sep 2000 00:01:05 GMT
Content-Type: plain/text
Content-Length: 11

hello world

MIME Types

Accept: */*
Accept: text/plain, image/png

Content-Type: text/plain
Content-Type: text/plain; charset=utf-8
Content-Type: text/html
Content-Type: text/css
Content-Type: text/javascript
Content-Type: application/json
Content-Type: image/png
Content-Type: image/svg+xml

See RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types (1996.11).

Content Encoding: Compression

Request

Accept-Encoding: zstd;q=1, br;q=0.8, gzip;q=0.5, deflate;q=0.1

q means quality value, also called weight, range from 0.0 to 1.1.

zstd means Zstd algorithm, open source by Facebook in 2016.

br means Brotli algorithm, created by Google in 2015.

More to see Compression on Linux Cookbook.

Response

Content-Encoding: zstd
Content-Encoding: br
Content-Encoding: gzip

Transfer Encoding

Transfer-Encoding: chunked

Internation (I18n)

Request

Accept-Language: en-US
Accept-Langauge: zh-CN, zh-Hans;q=0.9

Accept-Charset: utf-8
Accept-Charset: utf-8, iso-8859-1

Response

Content-Type: text/plain; charset=utf-8

Content-Language: en-US
Content-Language: zh-Hans

References