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
- HTTP - MDN
- David Gourley & Brian Totty. HTTP: The Definitive Guide (2002) ISBN: 978-1-56592-509-0 (《HTTP权威指南》)
- RFC 9112 - HTTP/1.1 (2022.6) (Obsolete RFC 2068, RFC 2616, RFC 7230)
- RFC 9110 - HTTP Semantics (2022.6) (Obsolete RFC 7231, RFC 7232)
- RFC 2817 - Upgrading to TLS Within HTTP/1.1 (2000) (Obsoleted by RFC 9112 and RFC 9110)
- RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types (1996.11)
- RFC 3676 - The Text/Plain Format and DelSp Parameters (2004.2) (Obsolete RFC 2646)
- RFC 5147 - URI Fragment Identifiers for the text/plain Media Type (2008.4)
- RFC 6657 - Update to MIME regarding “charset” Parameter Handling in Textual Media Types (2012.7)
- HTTP - Hypertext Transfer Protocol - W3C
- HTTP- Wikipedia
- HTTPS - Wikipedia