HTTP protocol learning, post to get; test request with Fiddler

Source: Internet
Author: User
Tags ranges

1. Introduction:

HTTP protocol: Hypertext Transfer Protocol Hypertext Transfer Protocol

It is an application layer protocol in the TCP/IP protocol set.

The format used to define the process and data for exchanging data between a Web browser and a Web server.

2. Session Mode:

1. Create a link 2. The client sends the request to server 3. Server Response 4. Close link

The progress of 3.http/1.1 than http/1.0

1. One icp/ip can contain multiple HTTP requests and responses

(In this way, multiple images in a Web page can be transferred in one TCP/IP (http/1.0 each image requires a TCP/IP connection). However, each individual Web file must have a separate TCP/IP connection established)

2. Multiple requests and responses and simultaneous.

(A separate ICP/IP connection for a Web page.) After the first request is sent, you can send a second request without waiting for the first response to complete. )

(The server echoes the results in the order in which the client requests.) )

3. Add more request headers and response headers. For example, to increase the host request header, you can use the hostname to indicate access to the Web site above the server.

4.HTTP Request Message

Structure of the request message: 1. A request line (Request request URL http version) 2. A number of message headers (optional, not available) 3. Entity content (GET request not, and only post, PUT, Delete, request) The message header and the entity's contents are separated by a blank line (representing The message header ends, and the empty line is followed by the entity content. Press the ENTER key to do so)

5.HTTP Response Message

Structure of the response message: 1. A status line 2. Several message headers (optional, not available) 3. The Entity content (which can not be) is separated by a blank line between the message header and the entity's content (representing the end of the message header, and the entity content behind the empty line). Entity content is the source code of the Web page)


6. message header function:

Equivalent to the instructions before the server and browser.

The browser uses the message header to pass information to the server: 1. Passing the language of his own country Accept-language 2. Tell the server which link from the current page is accessed ...

The server tells the browser: 1. Tell the browser what character set to use to display page 2. Create a cookie on the client ...

Format: Name: space value (multiple values separated by a number) enter. Some headers can appear several times. Case-insensitive, default, capitalize each word first letter.

7. Test with the Telnet command

1.telnet localhost 80
2. Press ' CTRL +] ' to turn on the native echo function.
3. Press ENTER
4.get/a.htm http/1.0 Enter, then press ENTER.

Request Case in http/1.0:
Get/a.html http/1.0

http/1.1 OK
Content-length:16
Content-type:text/html
Last-modified:tue, Oct 07:14:37 GMT
Accept-ranges:bytes
ETag: "885ba7e66dabcd1:7d4"
server:microsoft-iis/6.0
X-powered-by:asp.net
Date:sat, Oct 07:31:58 GMT
Connection:close

var data= "12345"

(Var data= "12345" is the Web content of a.htm)

Request case in http/1.1 (the status line must be followed by a blank line followed by the host):

Get/1.htm http/1.1
HOST:

http/1.1 OK
content-length:427
Content-type:text/html
Last-modified:sun, Oct 11:23:57 GMT
Accept-ranges:bytes
ETag: "F82BCC8F7EAFCD1:7DC"
server:microsoft-iis/6.0
X-powered-by:asp.net
Date:sun, Oct 11:24:33 GMT

Nobelium?html>
<title>does GET request can auto transfer input ' s para in url?</title>
<body>
<form method= "Get" action= "http://127.0.0.1/Default.aspx" enctype= "Applicat
Ion/x-www-form-urlencoded ">
Username:<input id= "txtUserName" type= "text"/>
Password:<input id= "Txtpassword" type= "text"/>
<input id= "Submit1" type= "Submit" value= "Submit"/>
</form>
</body>

Simple Request: The content of the get/1.htm response: Only the entity content does not have the message first class.

Post Request case:

Post/default.aspx http/1.1
HOST:
content-type:application/x-www-form-urlencoded
Content-length:35

username=zhangsan&password=123456
http/1.1 OK
Date:sun, Oct 11:33:40 GMT
server:microsoft-iis/6.0
X-powered-by:asp.net
x-aspnet-version:4.0.30319
Cache-control:private
content-type:text/html; Charset=utf-8
content-length:545

Form type can get parameter,username:zhangsan,password:123456


<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.or
G/tr/xhtml1/dtd/xhtml1-transitional.dtd ">


</title><body>
<form name= "Form1" method= "post" action= "default.aspx" Id= "Form1" >
<input type= "hidden" name= "__viewstate" id= "__viewstate" value= "/wepdwullte2mty2
Odcymjlkzjxyqvltbvdt/s4ng8fm3qcn72rqinw53mcr7ppt+9kf "/>

<div>
</div>
</form>
</body>

Note : 1. The Content-type must be application/x-www-form-urlencoded to obtain the submitted data.
2. Here content-length calculation is passed if content-length:35
3. To separate the message header from the entity content, press the ENTER key 2 times

8 Response Status Code

Common Status Codes:

9 General Information Header:

Includes some message headers that are not related to the content of the entity being transferred. (That is, the message header that can be used for the request, and the message header that can be used for the response)

Cacle-control:no-cache the cache is not saved after the request is completed, the next time the server is re-requested

Connection:close after the request is complete, disconnect. Cannot continue to make a request. Telnet: get/1.htm http/1.1 Host:Connection:close http/1.1 OK ... The connection to the host has been lost.

Date: Day

Pragma:no-cache

Trailer:date

transfer-encoding:chunked Segmented transfer

upgrade:http/2.0,shttp/1.3

via:http/1.1 Proxy1, http/1.1 Proxy2 Proxy Server

Warning:any text


Application/json; Charset=utf-8

content-length:398 (This is what you want with the character length of your request body, can not input, automatic calculation)

5. Enter, Requst boy, for example:

{"UserName": "Logic5", "Password": "Test1234", "FirstName": "Ivan", "LastName": "Chen", "lastlogindate": "2010-01-01", " Email ":" [email protected], "CreateDate": "2010-01-01", "lastpasswordchangeddate": "2010-01-01", "Lastlockoutdate": " 2010-01-01 "," islockedout ": True," isapproved ": false," disabledate ":" 2010-01-01 "," isdisable ": false," profile ": {" Tins ":" 743222298 "," ProviderID ": 168829," UserName ":" Logic5 "}}

Click Execute and the operation is successful!

HTTP protocol learning, post to get; test request with Fiddler

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.