In-depth research form submission method: GET/POST

Source: Internet
Author: User
You know that the current form submission methods include GET and POST. I will not talk about anything here. I will show you a request to submit a form in the GET method. we all know that the current form submission methods include GET and POST. I will not talk about anything here. I will show you a request to submit a form in GET mode:

GET/cgi-bin/tech/method. cgi? GET = get http/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd. ms-powerpoint, application/vnd. ms-excel, application/msword ,*/*
Referer: http: // localhost // other.html
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Host: localhost: 8080
Connection: Keep-Alive

This request is sent through the HTML code:

 

This request has exceeded our research scope and we only study the first row. The first "GET" indicates the submission method, which is submitted in the GET method. the intermediate one is the program submitted to the server, previous section "/cgi-bin/tech/method. cgi "is the content of action in the form of HTML, and" GET = GET "is the content of input in the form of HTML: we found that IE has converted the content of this form into a specific format. In Perl, GET the data sent with GET through $ GET = $ ENV {'query _ string.

Let's look at another form request submitted in POST mode:

POST/cgi-bin/tech/method. cgi HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd. ms-
Powerpoint, application/vnd. ms-excel, application/msword ,*/*
Referer: http: // localhost // other.html
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Host: localhost: 8080
Content-Length: 9
Connection: Keep-Alive

POST = POST

HTML is also given:

 

We found that the data ran to the bottom. In Perl, data sent in POST is obtained through read (STDIN, $ POST, $ ENV {'content _ length. I remember that GET can only send up to 1024 bytes of data, while POST seems very big!

Think: If I have such an HTML code, what will happen to it?

 

This code may have been used in many programs, but most people will not think about it. what content is sent by GET and what content is sent by POST. Let's see what its request is:

POST/cgi-bin/tech/method. cgi? GET = get http/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd. ms-
Powerpoint, application/vnd. ms-excel, application/msword ,*/*
Referer: http: // localhost // other.html
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Host: localhost: 8080
Content-Length: 9
Connection: Keep-Alive

POST = POST

Ha! It was originally sent by POST. However, you must have found that some of the data is placed in the first row, which is the same as GET. In fact, this example is very typical. it is a mix of POST and GET!
I don't believe you can use read (STDIN, $ POST, $ ENV {'content _ length'}) and $ GET =$ ENV {'query _ string'} in Perl, which contains the "GET = GET" data.

I will provide devices for you to study by yourself:

HTML section:

 
 
Get-Post 
 

 
 
 
 
 
 
 

Perl section:

#! C: \ perl \ bin \ perl.exe

$ | = 1;

Print "Content-type: text/html \ n ";

Print "sending METHOD: $ ENV {'request _ method '}
\ N ";
If (read (STDIN, $ POST, $ ENV {'content _ length '})){
Print "POST data: $ POST
\ N ";
}
If ($ GET = $ ENV {'query _ string '}){
Print "GET data: $ GET
\ N ";
}

$ METHOD = "POST ";

For ($ I = 0; $ I <= 1; $ I ++ ){
Foreach (split (//, $ METHOD )){
$ _ = ~ S/\ + // g;
($ Name, $ value) = split (/=/, $ _);
$ Name = ~ S/% ([a-fA-f0-9] [a-fA-f0-9])/pack ("C", hex ($1)/eg;
$ Value = ~ S/% ([a-fA-f0-9] [a-fA-f0-9])/pack ("C", hex ($1)/eg;
$ METHOD {$ name} = $ value;
}
$ METHOD = "GET ";
}


$ METHOD = "POST ";

For ($ I = 0; $ I <= 1; $ I ++ ){
Print "Hash form $ METHOD data traversal:
\ N ";
Foreach (keys % {$ METHOD }){
Print "\ $". $ METHOD. "{". $ _. "}=$ $ METHOD {$ _}
\ N ";
}
Print"
\ N ";
$ METHOD = "GET ";
}

Exit;


#### Code end ####


Well, what I want to say is, what is the significance of this research?
Meaning: let you know which data submitted by the user uses the POST method and the GET method!
In fact, the Perl code above already includes a lot of technologies. After reading this article, you can know that % GET is submitted in GET mode, and % POST is the same!

If you are interested in the Perl code I have written, please refer to QQ: 106814. As for how to obtain requests sent by IE, I would like to say that I use a Server compiled by Perl to listen to port 8080. do I write most of my work like Ohm (of course, it is a little difficult for me to write an operating system, but WebServer can work together )? Joke!

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.