telnet发送http请求 [英] telnet send a http request

查看:591
本文介绍了telnet发送http请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用telnet发送http请求,如下所示:

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.

响应代码为200,但为什么会出现这样的段落:

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>

这是服务器或telnet本身的输出?如何避免显示这个?

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

- 更新 -
当我将HTTP / 1.1更改为http / 1.1时,我得到了正确的权利响应。
现在我想知道这是协议的要求还是与服务器的实现有关?

--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?

推荐答案

HTTP 1.1 中,所有连接都被视为持久性除非另有声明。

In HTTP 1.1, all connections are considered persistent unless declared otherwise.

然后......我认为服务器正在接收一些虚假的换行符,并回复错误请求

Then... I think the server is receiving some spurious newline char and reply with a Bad Request.

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

If you use http/1.1 instead of HTTP/1.1 could make fallback the version to the version 1.0 that's not persistent by default and after the 200 OK response it drops the connection.

这篇关于telnet发送http请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆