post 消息
几个必要字段格式。
C/C++ code
"POST %s HTTP/1.1\r\n" \
"Accept: */*\r\n" \
"Content-Type: application/x-www-form-urlencoded\r\n" \
"User-Agent: Mozilla/4.0 (compatible; MPUD %s)\r\n" \
"Host: %s\r\n" \"Cache-Control: no-cache\r\n" \
"Connection: Keep-Alive\r\n" \
"Content-Length: %d\r\n" \
"\r\n"
"%s"
我登录VCKBASE抓的包如下,注意换行符。
C/C++ code
POST /SYS/login/login.aspx HTTP/1.1
Host: www.vckbase.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.vckbase.com/
Cookie: ASPSESSIONIDCSAATTCD=DOMMILABJOPANJPNNAKAMCPK
Content-Type: application/x-www-form-urlencoded
Content-Length: 79
userid=aaaaaaa&password=01234567890&gclsid=501&imageField3.x=43&imageField3.y=11
POST /SYS/login/login.aspx HTTP/1.1
Host: www.vckbase.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/2008052906 Firefox/3.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.vckbase.com/
Cookie: ASPSESSIONIDCSAATTCD=DOMMILABJOPANJPNNAKAMCPK
Content-Type: application/x-www-form-urlencoded
Content-Length: 79
userid=aaaaaaa&password=01234567890&gclsid=501&imageField3.x=43&imageField3.y=11
24楼的这个就是例子。需要特别注意的是Content-Length后的数据长度值一定要正确,是获取的数据体部分的字节长度,具体就是 userid=aaaaaaa&password=01234567890&gclsid=501&imageField3.x=43&imageField3.y=11 这部分对应的数据。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/andylin02/archive/2008/10/24/3137357.aspx