2013-05-17 47 views
1

假設我有first=Johnlast=Doe及以下網址:http://<myurl>/<my controller>http post請求的標題和正文如何?

如何將HTTP消息(標題和正文)看起來像一個客戶端接收HTTP Post嗎?

+1

使用哪種編碼?另外,你爲什麼問?你有特定的問題嗎?使用特定的代碼? –

+0

@JohnSaunders UTF-8;我在問,因爲我好奇;我沒有問題;沒有具體的代碼 – cybertextron

+0

[如何模仿POST請求中的HTML表單提交?](http://stackoverflow.com/questions/8417224/how-to-mimic-an-html-form-submission-in-一個請求後) –

回答

1

像下面的東西。您可以使用螢火蟲瀏覽器插件檢查原始HTTP通訊。您也可以通過read this article瞭解更多詳情。

POST /mycontroller HTTP/1.1 
Host: localhost 
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729) 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Connection: keep-alive 
Content-Type: application/x-www-form-urlencoded 
Content-Length: 20 

first=John&last=Doe