2013年8月28日星期三

Server sends back HTTP/1.1 400 Bad Request

linux, using C to write a SOCKET sent to the server over an HTTP request, (static const char * request = "GET / index.html HTTP/1.1 \ r \ n \ r \ n ";) This is just test results sent back to the server
HTTP/1.1 400 Bad Request
Date: Wed, 21 Aug 2013 08:59:32 GMT
Server: Apache/2.2.24 (Unix)
Content-Length: 226
Connection: close
Content-Type: text / html; charset = iso-8859-1

and there are a
Your browser sent a request that this server could not understand

This is not normal ah, seeking god Weapon, newcomers gratitude! !

------ Solution ------------------------------------ --------
with web access, use wireshark capture, and then fill out the contents of the installation package.
------ Solution ---------------------------------------- ----
bring Host try again.
------ Solution -------------------------- ------------------
GET this should be the format, and I use to access Baidu package wireshark catch, with a lot of lines with a GET packet contents:
GET / HTTP/1.1 \ r \ n
Host: www.baidu.com \ r \ n
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv: 23.0) Gecko/20100101 Firefox/23.0 \ r \ n
Accept: text / html, application / xhtml + xml, application / xml; q = 0.9, * / *; q = 0.8 \ r \ n
Accept-Language: zh-cn, zh; q = 0.8, en-us; q = 0.5, en; q = 0.3 \ r \ n
Accept-Encoding: gzip, deflate \ r \ n
Cookie: BAIDUID = A21FE77A3E5A4A8B26A82120C14E891B: FG = 1; CNZZDATA30081939 = cnzz_eid% 3D941235294-1376885338-http% 253A% 252F% 252Fwww.baidu.com% 26ntime% 3D1376885338% 26cnzz_a% 3D0% 26retime% 3D1376885338015% 26sin% 3D% 26ltime% 3D1376885338015% 26rtime% 3D0; BDREFER =% 7Burl% 3A% 22http% 3A / / mil.news.baidu.com /% 22% 2Cword% 3A% 22% 22% 7D; H_PS_PSSID = 3157_2777_1429_3139_2785_2981_3092_3108_2701 \ r \ n
Connection: keep-alive \ r \ n \ r \ n
I put the contents of the hair in the past, successfully received a reply:
HTTP/1.1 200 OK
Date: Thu, 22 Aug 2013 02:56:52 GMT
Server: BWS/1.0
Content-Length: 4491
Content-Type: text / html; charset = utf-8
Cache-Control: private
BDPAGETYPE: 1
BDUSERID: 0
BDQID: 0xac102fc8007bef3a
Set-Cookie: BDSVRTM = 2; path = /
Set-Cookie: H_PS_PSSID = 3157_2777_1429_3139_2785_2981_3092_3108_2701; path = /; domain =. baidu.com
Expires: Thu, 22 Aug 2013 02:56:52 GMT
Content-Encoding: gzip
Connection: Keep-Alive
------ For reference only --------------------------- ------------
that I wrote a problem wood ah, the problem lies in what ah, seeking guidance
------ For reference only ----- ----------------------------------
Yes, I try HOST
--- --- For reference only ---------------------------------------
HTTP / 1.1 400 Bad Request
Date: Thu, 22 Aug 2013 02:16:19 GMT
Server: Apache/2.2.24 (Unix)
Content-Length: 226
Connection: close
Content-Type: text / html; charset = iso-8859-1





Bad Request


Your browser sent a request that this server could not understand.




------ For reference only ---------------------------------- -----
is POST it
------ For reference only --------------------------- ------------
I use Http Watch looks like you are not the same ah. I am a novice

没有评论:

发表评论