我遇到奇怪的行爲通過socket做的HTTP請求時,此請求:HTTP請求,奇怪的插座行爲
POST https://example.com:443/service/XMLSelect HTTP/1.1
Content-Length: 10926
Host: example.com
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)
Authorization: Basic XXX
SOAPAction: http://example.com/SubmitXml
後來還有我與給定的內容長度的請求的身體。 之後,我收到這樣的:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Tue, 30 Mar 2010 06:13:52 GMT
所以一切都似乎是在這裏很好。我從網絡流中讀取所有內容併成功接收響應。但我的插座,我在做投票開關它是這樣的模式:
write (i write headers and request here)
read (after headers sent i begin to receive response)
write (STRANGE BEHAVIOUR HERE. WHY? here i send nothing really)
read (here it switches to read back again)
最後兩個步驟可以重複幾次。所以我想問一下爲什麼會導致socket的模式改變?而在這種情況下,它不是一個大問題,但是當我使用gzip壓縮在我的要求(不知道它是如何相關的),並要求服務器gzip壓縮的響應發送到我這個樣子:
POST https://example.com:443/service/XMLSelect HTTP/1.1
Content-Length: 1076
Accept-Encoding: gzip
Content-Encoding: gzip
Host: example.com
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)
Authorization: Basic XXX
SOAPAction: http://example.com/SubmitXml
我收到的反應一樣, :
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Encoding: gzip
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Tue, 30 Mar 2010 07:26:33 GMT
2000
�
我收到一個塊大小和GZIP頭,沒關係。這裏還有什麼是我的可憐的小插座同時在發生:
write (i write headers and request here)
read (after headers sent i begin to receive response)
write (STRANGE BEHAVIOUR HERE. And it finally sits here forever waiting for me to send something! But if i refer to HTTP I don't have to send anything more!)
那是什麼關係?它想要我發送什麼?它是遠程Web服務器的問題還是我錯過了什麼?
PS所有實際服務引用和登錄/密碼有假的:)
小的一點,但示例URL應使用RFC2606保留域之一[http://www.rfc-editor.org/rfc/rfc2606.txt],如example.com - 保證永遠不會指向活的域名如果有人在任何地方做任何事情複製/粘貼示例代碼 – Gareth 2010-03-30 07:43:46
行動,我很抱歉,換成正確的:)我的問題呢? – hoodoos 2010-03-30 07:45:23