2014-07-10 190 views
1

我知道這是很簡單的,但我不能弄清楚,如果我做這樣通過telnet請求:無法通過telnet發送POST變量?

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 = e3因爲我有一條PHP行輸出它:

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

但是該變量沒有出現。我錯過了什麼嗎?

回答

2

嘗試添加Content-type頭:

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

工作就像一個魅力!謝謝!但是,如果我在主題中省略主持人,爲什麼我會獲得400錯誤請求? – tonix

+0

如果你忽略了'Host:'它不知道你想要哪個虛擬主機。 – Barmar