如何使用Telnet生成HTTP POST请求?

时间:2017-08-31 14:31:49

标签: http post request telnet

有谁知道如何在请求中添加HTTP正文参数?我尝试过像......

telnet xxxx.com 80
Trying 128.x.xxx.45...
Connected to xxxx.com.
Escape character is '^]'.
POST /webapps/methods/check-post HTTP/1.1
Host: xxxx.com
Content-Type: application/json; charset=utf-8
{"id":"myid","color":"blue"}

但是我得到了一个400的错误请求'响应

HTTP/1.1 400 Bad Request
Date: Thu, 31 Aug 2017 13:54:32 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 311
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at xxxx.com Port 80</address>
</body></html>
Connection closed by foreign host.

任何人都可以帮助我使用Telnet设置正确的HTTP post请求吗?

1 个答案:

答案 0 :(得分:0)

只需在HTTP请求标头和HTTP请求主体之间添加另一个空行。参数应类似于:key1=value1&key2=value2