7

I am using telnet to send a http request , like this:

telnet> open 192.168.4.135 8087
Trying 192.168.4.135...
Connected to 192.168.4.135.
Escape character is '^]'.
POST /rpc/ HTTP/1.1
HOST:192.168.4.135:8087
Content-length:18
Content-type:application/x-http-form-urlencoded

action=loadrsctype
HTTP/1.1 200 OK
Date: Thu, 17 May 2012 03:52:53 GMT
Content-Length: 45
Content-Type: text/html; charset=ISO-8859-1

return=fail&error=Configuration doesn't existHTTP/1.1 400 Bad Request
Content-Type: text/html
Connection: close
Date: Thu, 17 May 2012 03:52:53 GMT
Content-Length: 94

<HTML><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Bad Request</H1>
</BODY></HTML>
Connection closed by foreign host.

the response code is 200 , but why there is a paragraph like this :

HTTP/1.1 400 Bad Request
Content-Type: text/html
Connection: close
Date: Thu, 17 May 2012 03:52:53 GMT
Content-Length: 94

<HTML><HEAD>
<TITLE>400 Bad Request</TITLE>
</HEAD><BODY>
<H1>Bad Request</H1>
</BODY></HTML>

This is the output of the server or telnet itself ? How to avoid to show this ?

--update-- When i change "HTTP/1.1" to "http/1.1", i get the right response. Now i wonder wheather this is requirement of protocol or related with the implementation of the server?

4

3 回答 3

5

在中,除非另有声明,否则HTTP 1.1将考虑所有连接。persistent

然后...我认为服务器正在接收一些虚假的换行符并以Bad Request.

如果您使用http/1.1而不是HTTP/1.1可以将版本回退到1.0默认情况下不持久的版本,并且在200 OK响应之后它会断开连接。

于 2013-02-15T16:01:28.657 回答
1

尝试替换&&amp;.

于 2013-02-15T15:44:41.817 回答
0

您正在访问的 URL 处的代码正在打印一些文本:

return=fail&error=Configuration doesn't exist

但随后您的代码继续打印 HTTP 400 错误。可能您在打印响应后忘记中止,因此您的代码也继续打印 HTTP 400。

于 2012-05-17T04:20:04.070 回答