HTTP 协议

2018-05-15  本文已影响29人  michael_jia

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

http status code

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上的例子很好地诠释了这个原因,如下图:

mozilla.org上的 chunked 编码示例
Meta refresh
<meta http-equiv="refresh" content="5; url=http://example.com/">
Refresh Header
3 ways of redirection
URL Redirection
<body onload="window.location = 'http://example.com/'">
<!-- Your content here -->
</body>

HTTP 1.0 vs 1.1

上一篇下一篇

猜你喜欢

热点阅读