HTTP protocol (80 port)
HTTPS (443 port)
Mainly has been to three times the handshake is vague, and grabbed the bag when do not know those accept, user-agent what meaning, on the course to learn a bit carefully.
Learn about:
1, involving Tools (Wireshark, fiddler)
2, request message (Request line, request header, request body)
3. Reply Message (answer line, answer header, reply body)
4. HTTP Capture Tool
I'll start with Wireshark. TCP Three-time handshake-Send request-Request response-Request status code
1. Three-time handshake,
2. The response is done,
After finding 2 request messages on the Fiddler, we start to check what the parameters in the request mean.
Request message (Request line, request header, request body)
Example:
GET/?a1004 http/1.1
Accept : */*
accept-language : ZH-CN
user-agent : mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; trident/4.0; GTB7.5; SLCC2;. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729; Media Center PC 6.0;. net4.0c;. net4.0e; infopath.3)
accept-encoding : gzip, deflate
proxy-connection : keep-alive
Host : hao.360.cn
cookies: count=12; somultiswitch=1; tweetsiteflag2= 1; city_code=101280109; Sidebarstipstatus=20160401yule0401_1; sessionid=132730903.3951674013491768000.1492047237189.6052; Logwtb=1; Logwtb2=1; Logwtb3=1; Logwtb4=1; Channelorder=a_8_e_ob; CUSTOMENG=4-13; __guid=132730903.3884126908240207400.1490749650870.3637; _ga=ga1.2.1007699322.1491787380; __gid=206785792.819567615.1491960528189.1491960563795.3; __huid=11l1zl6fepyhidednchxoun1ey9+atvi8ezujtciev8/o=; __hsid=b3ebde9e0c285f61
1. Request Line
Example: Get/mainpage.aspx http/1.1\r\n
Explanation: Request method Request URL HTTP version
1. Request method
Http1.1:7 method of Request
1.Get
2.Post
3.Head
4.Options
5.Put
6.Delete
7.Trace
Question what is the difference between a GET request and a POST request?
Get data from the server
Post sends data to the server
I thought get was a request, the post was an answer, it was corrected, it was a request.
2. Request Header
Explain:
1.host:hao.360.cn,
Specifies the requested Internet host and port number, which is the location of the original server (gateway)
http/1.1 request must contain host header domain, otherwise 400 status code (server) is returned
2.user-agent:
Indicate some information about the request, browser type and version, operating system, etc.
The information here usually does data collection, which can analyze what browser users use to access our services
3.Accept: */*
Specifies which types of responses the client accepts, the format that can be opened directly in the customer's browser
Often: accept:image/png,image/*;q=0.8,*/*;q=0.5
Q What does the question mean?
4.accept-language:zh-cn
Refers to the client's operating system language
Often: accept-language:zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
5.accept-encoding:gzip, deflate
This property represents the encoding rule or format specification that the client can accept, and deflate should be a generic
6.Referer: URL
Understood as the last dependent request (address) of the current request, can be an absolute path/relative path, and the host is stitched into a full URL address
7.proxy-connection:keep-alive
Connection:keep-alive
Indicates how long links are handled when the client and server communicate, and both parties in http1.1 default to support long connections and do not use long links, the value is close. Which side does not want to support long links, connection is close in the header of Reques or response.
Questions about long links and short connections?
Short link: The TCP link that is currently being used is broken after the current request is processed and the client creates a new TCP at the time of the new request
Other: Date, POxy, Cache-control, and cookies are literally understood.
3. Request Body
Get requests usually have no request body
The POST request body, such as Username=chen&pwd=12345&check=on, looks like the body in the web_custom_request in LR
Second, reply message (head, line, body)
Example:
http/1.1 503 Service Unavailable
Cache-control:no-cache
Pragma:no-cache
content-type:text/html; Charset=utf-8
Proxy-connection:close
Connection:close
content-length:787
1. Answer Line
3 examples were collected
http/1.1 OK
http/1.1 503 Service Unavailable
http/1.1 304 Not Modified
Version HTTP request answer return code English name
Also collate the HTTP request answer return code
This is a successful request, generally used for Get and post requests, 304 unmodified not Modified, 503 due to overloading or system maintenance, the server temporarily cannot process the request, the delay can be included in the response header of the Retry-after attribute Service unavailable
2. Answer Header
Cache-control:no-cache
Pragma:no-cache
content-type:text/html; Charset=utf-8
Proxy-connection:close
Connection:close
content-length:787
According to the introduction of the face of the request header, here is known to introduce the situation of the server, pay special attention to 1, content-encoding:gzip, refers to the content returned by the gzip compression technology; 2, content-length:787, refers to the length of the body returned
3. Answer text
Compression technology can be used, but HTML-based page information is generally
Third, the HTTP capture tool
1, Wireshark the expression of the protocol is more clear
2. Firefox Firebug search for Firebug components in Firefox tools-add-ons and install them
3, Chrome F12, I use this to see the front-end performance optimization
4, IE http watch, the most stable version 9.4, Web data analysis tools, support Firefox, support HTTPS
Capture tool I also use Fiddler, Firefox poster. Fiddler can set breakpoints to modify parameters, or it can be set to support capturing HTTPS. There are too many tools and there is no clear distinction between these categories.
Learn the details of the 1,http protocol