【问题标题】:Can't send POST variables through telnet?不能通过 telnet 发送 POST 变量?
【发布时间】:2014-09-01 05:48:38
【问题描述】:

我知道这很简单,但我想不通,如果我用 telnet 发出这样的请求:

machine:~ user$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
POST / HTTP/1.1
Host: localhost
Content-Length: 7

vari=e3
HTTP/1.1 200 OK
Date: Thu, 10 Jul 2014 18:06:33 GMT
Server: Apache/2.2.26 (Unix) mod_fastcgi/2.4.6 mod_wsgi/3.4 Python/2.7.6 PHP/5.5.10 mod_ssl/2.2.26 OpenSSL/0.9.8y DAV/2 mod_perl/2.0.8 Perl/v5.18.2
X-Powered-By: PHP/5.5.10
Content-Length: 7
Content-Type: text/html

VARI = 

没有设置 vari 变量...响应应该有 VARI = e3 因为我有一个输出它的 PHP 行:

echo "VARI = ".$_POST['vari'];
exit;

但是变量没有出现。我错过了什么吗?

【问题讨论】:

    标签: php telnet


    【解决方案1】:

    尝试添加Content-type 标头:

    Content-type: application/x-www-form-urlencoded
    

    【讨论】:

    • 工作就像一个魅力!谢谢!但是,如果我在标头中省略 Host:,为什么会收到 400 Bad Request?
    • 如果你忽略Host:,它不知道你想要哪个虚拟主机。
    猜你喜欢
    • 2017-04-30
    • 2014-01-30
    • 1970-01-01
    • 2017-10-30
    • 2016-05-15
    • 1970-01-01
    • 2012-01-02
    • 1970-01-01
    • 2011-11-06
    相关资源
    最近更新 更多