深入研究表单提交方式:GET/POST

下改变世界的人

下改变世界的人

2016-01-29 13:30

深入研究表单提交方式:GET/POST,深入研究表单提交方式:GET/POST

大家知道目前表单提交的方式有GET和POST。我在这里不多说什么,给大家看一个以GET方式提交的表单的请求: 

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: 

::URL::

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)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 

  这个请求是我们通过这个HTML代码发出的: 

<form action="

::URL::

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)http://localhost:8080/cgi-bin/tech/method.cgi"  method="GET" 
<input type="text" size="10" value="GET" name="GET" 
<input type=submit value="GET方式" 
</form 

  这个请求已经超出了我们研究的范围,我们只研究其中的第一行。其中,第一个"GET"说出了提交的方式,是以GET方式提交的;中间的就是提交给服务器上哪个程序,前面一部分"/cgi-bin/tech/method.cgi"就是我们HTML的form中action的内容,而后面的"GET=GET"就是HTML的form中,input的内容:我们发现IE已经把这个表单的内容转换成特定格式了。在Perl中,通过$GET=$ENV{'QUERY_STRING'}获得以GET发送的数据。 

  我们再看一个以POST方式提交的表单的请求: 

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: 

::URL::

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)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: 

<form action="

::URL::

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)http://localhost:8080/cgi-bin/tech/method.cgi"  method="POST" 
<input type="text" size="10" value="POST" name="POST" 
<input type=submit value="POST方式" 
</form 

  我们发现其中的数据跑到了最下面。在Perl中,通过read(STDIN,$POST,$ENV{'CONTENT_LENGTH'})获得以POST发送的数据。我记得GET发送数据最多只能1024字节,而POST好像很大很大! 

  思考:如果我有这么一段HTML代码,它将会出现什么问题呢? 

<form action="

::URL::

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)http://localhost:8080/cgi-bin/tech/method.cgi?GET=GET"  method="POST" 
<input type="text" size="10" value="POST" name="POST" 
<input type=submit value="GET/POST方式" 
</form 

  这个代码在很多程序上可能用到过,但是大多数人不会好好的想一想,究竟哪些内容是以GET发送的,哪些内容是以POST发送的。我们看看它的请求是什么: 

POST /cgi-bin/tech/meth
展开更多 50%)
分享

猜你喜欢

深入研究表单提交方式:GET/POST

PHP
深入研究表单提交方式:GET/POST

转-类的深入研究

编程语言 网络编程
转-类的深入研究

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

驯服Tiger之深入研究枚举类型

编程语言 网络编程
驯服Tiger之深入研究枚举类型

CSS之绝对定位深入研究

Web开发
CSS之绝对定位深入研究

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

深入研究Application和Session对象

ASP
深入研究Application和Session对象

高手必修:关于FoxMail的深入研究

编程语言 网络编程
高手必修:关于FoxMail的深入研究

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Flash模拟360度互动环景的简单方法(1)

Flash模拟360度互动环景的简单方法(1)

顺序求出c(n,r)的排列组合

顺序求出c(n,r)的排列组合
下拉加载更多内容 ↓