Interface Test Lesson Three (Introduction to HTTP protocol)--reprint

Source: Internet
Author: User

First, open the Baidu URL detailed:

Open Baidu Web site with a browser, enter any keyword search:

  

The detailed URL address is copied as follows

Https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=monline_3_dg&wd=%E6%B5%8B%E8%AF %95&rsv_pq=d87c123200060e83&rsv_t=34df3nkqrkkypm5mjckqszvivrnqpn%2b1h9csxlpzmi% 2fmhca48ccykzrhtt9zzjluwv0x&rsv_enter=1&rsv_sug3=1

The packets captured in Fiddler are as follows, and the Red box area

Second, the URL mode

The URL (Uniform Resource Locator) address is used to describe a resource on a network with the following basic format

Scheme Specifies the protocol used by the lower layer (for example: HTTP, HTTPS, FTP)

The IP address or domain name of the host HTTP server

The default port for the port# HTTP server is 80, in which case the lower number can be omitted. If you use a different port, you must specify, for example, http://www.cnblogs.com:8080/

Path to access resource

Url-params

Query-string data sent to the HTTP server

anchor-Anchor

  

 
From this you can see the details of the visit Baidu URL:

    1. Request type (scheme): HTTPS

    2. Host:www.baidu.com

    3. Path:/s

    4. Request parameters (Url-params): Ie=utf-8&f=3&rsv_bp=1& (with & separated by the question mark)

    5. Server return status (Result): 200 (Request succeeded)

Iii. differences between get and post methods

The HTTP protocol defines a number of ways to interact with the server, the most basic of which are 4, get,post,put,delete, respectively. A URL address is used to describe a resource on a network, and the Get, POST, PUT, delete in HTTP corresponds to the search for this resource, change, increase, delete 4 operations. Our most common is get and post. Get is typically used to get/query resource information, and post is typically used to update resource information.

Let's look at the difference between get and post

1. Get submitted data will be placed after the URL, to split the URL and transfer data, the parameters are connected with &, such as editposts.aspx?name=test1&id=123456. The Post method is to put the submitted data in the body of the HTTP packet.

2. The data size of the Get commit is limited (because the browser has a limit on the length of the URL), and there is no limit to the data submitted by the Post method.

3. The Get method needs to use Request.QueryString to get the value of the variable, while the Post method obtains the value of the variable by Request.Form.

4. The Get method submits the data, which brings security issues, such as a login page, when the data is submitted by get, the user name and password will appear on the URL, if the page can be cached or other people can access the machine, you can obtain the user's account and password from the history.

Iv. How to use fiddler to see if a request is a GET or post?

  

1) Click on the left, the URL to be viewed is selected

2) Click on the Right inspectors button

3) Click Headers

4) View request headers below: Get, description is GET request way

5) Just a little bit more. Other URLs in the left-hand area, you can find the POST request

  

V. View request and Response

First look at the Fiddler working principle

  


That is, terminal equipment issued a request, fiddler as an agent, to the server;

The server returns data, fiddler interception, and then to the end device.

Fiddler the request data is displayed in the upper right area and the lower area shows the response data.
  

Vi. what is different about get and POST request parameters

Get requests such as:

  


Post requests such as

  

The most obvious difference is that the POST request is one more area called the body body.

That is, get request without body;post request with body

Vii. How do I see if the request server was successful?

  

Common Status Codes:

200-Server successfully returned to Web page
301-Permanently moved, the requested page has been permanently moved to a new location
404-The requested page does not exist and the page does not exist.
500-The server encountered an error and could not complete the request.
502-The server received an invalid response from the upstream server as a gateway or proxy
503-The server is temporarily unavailable and cannot be used at this time (due to overloading or downtime maintenance).

Interface Test Lesson Three (Introduction to HTTP protocol)--reprint

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.