HTTP 协议

HTTP(Hypertext Transfer Protocol) 是万维网通信的基石。

  • initiated by Tim Berners-Lee in 1989.
  • HTTP/1.0:RFC 1945;
    May 1996;
  • HTTP/1.1:RFC 2068 -> 2616 -> 7230-7235;
    January 1997 -> June 1999 -> June 2014
  • HTTP/2:RFC 7540;
    May 2015
  • List of HTTP status codes(标准 HTTP 状态码);
  • NGINX HTTP Return Codes;
  • List of HTTP header fields;
  • HTTP 标准 Header;
  • online URL Parser / Query String Splitter @ freeformatter.com;
  • base64,base64 在线编码、解码;
  • Nginx:HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server.
http status code
  • URL 可以多长?
    What is the maximum length of a URL in different browsers?
    最长保持在 2000 字节以内没问题;
  • 451
    Unavailable For Legal Reasons (RFC 7725);
  • Nginx 499 Client Closed Request(了解 LXR)

Used when the client has closed the request before the server could send a response.
Used in Nginx logs to indicate when the connection has been closed by client while the server is still processing its request, making server unable to send a status code back.
Client Error
The 4XX class of codes indicate you did something wrong. Specifically, there's an error on the client side.

http server @ github

a simple zero-configuration command-line http server.
使用非常简单;

Transfer-Encoding Header

Transfer-Encoding: chunked
开发 PHP 服务时,如果确切地知道返回的内容长度,一定要指定 Content-Length头,否则 Nginx 默认使用 chunked,因为它不知道何时结束,导致即使0字节的返回,网络上也有5个字节的内容传送(不包括 http header 的长度)。
mdn上的例子很好地诠释了这个原因,如下图:

HTTP 协议_第1张图片
mozilla.org上的 chunked 编码示例

Meta refresh
  • How to Use the Meta Refresh Tag?
  • 示例

  • drawbacks:impairs the web browser's "back" button;user dissatisfaction;
  • legitimate uses:Many large websites use it to refresh news or status updates, especially when dependencies on JavaScript and redirect headers are unwanted.
  • You should mention that automatic refresh can be disabled in some browsers.
Refresh Header
  • 不是 HTTP 标准 Header;
  • Netscape 创建的;
  • 被 W3C 通过 Meta refresh 方式所接纳;
3 ways of redirection
  • Via 3xx response (in the Location HTTP response header)
  • Via Javascript (or any other client side code) in the response page (e.g. document.location=...)
  • Via "META REFRESH" ()
  • Refresh Header was invented by Netscape ;
URL Redirection
  • URL 跳转
    The simplest way of JavaScript redirect using the onload property of the body tag:



HTTP 1.0 vs 1.1

  • Major differences between versions HTTP/1.0 and HTTP/1.1;

你可能感兴趣的:(HTTP 协议)