An article so that you completely understand what is http

Summary

This article describes the main content of what is http protocol, https protocol what is the difference between http and https protocol agreement, then we go ~

Before understanding the http protocol we first look at when we enter a url to the page rendering out what this process is what made it ~

Network open thread starts parsing url

DNS name, the query IP

Establish TCP / IP links

And send the request

What is the HTTP protocol:

HTTP Hypertext Transfer Protocol, a network protocol application layer protocol, it is a civilized agreement, transfer the contents of the external transfer process is visible.

HTTP features:

HTTP protocol is a protocol to transfer data to a TCP / IP-based communication, the data type may be the JSON, form, HTML, images, etc.

The default HTTP port number is 80

HTTP is the protocol is stateless, each request and response has nothing to do with each other (which is why the cause of Session, Cookie, Token of)

HTTP part

HTTP request

Request line

Request line there is a request method, URL field, a three-part HTTP protocol revision number

 

 

 HTTP request methods: POST GET PUT DELETE OPTIONS

Here need to understand, HTTP request is also divided into simple and complex requests with request

So how to meet a HTTP request is a simple request:

1HTTP type of request: HEAD, GET, POST

2HTTP头包含:Accept、Accept-Language、Content-Language、Last-Event-ID、Content-Type

       Content-Type is the only application / x-www-form-urlencoded, multipart / form-data, text / plain one

Complex requests:

If the request does not meet the conditions of a simple request is complex, a complex communication request, the request contains not only the content of the communication, but also includes a pre-request.

Comparison with a simple request complex requests:

Simple request

 

 Complex requests

 

 Wherein the request is a request type pre OPTIONS

 Request header

Requests for information to the client interprets

Request header common property (commonly used to explain the focus here):

Accept: Acceptable response type (application / json, text / plain, etc.)

Accept-Charest:可接收的字符集(utf-8等)

Accept-Encoding:可接受的相应内容的编码方式(gzip、deflate等)如下图

Accept-Language:可接受的响应内容语言列表(en-US、zh-CN等)

Authorization:http认证信息(oauth认证)

Cache-Control:缓存机制控制(on-cache、on-store、max-age、public、private)

Connection:客户端优先使用的链接类型(keep-alive、upgrade)

User-Agent:浏览器的身份标识字符串

Origin:发起一个针对跨域资源共享的请求

If-Modified-Since:上一次响应的Last-Modified的值回当做If-Modified-Since的值发送给服务器

If-None-Match:上一次响应的ETag的值会当做If-None-Match的值发送给服务器

Referer:表示跳转到当期那页面的之前页面

消息主题

HTTP响应

状态行

响应头

响应正文

Guess you like

Origin www.cnblogs.com/moran1992/p/12026568.html