我不知道为什么我的客户端/服务器通信不能像我测试的Apache服务器一样工作.
谢谢你的任何澄清……
客户端/服务器通信:
CLIENT: HEAD /stream.mpeg HTTP/1.0 Host: 127.0.0.1 User-Agent: SuperPlayer Connection: Close SERVER: HTTP/1.0 200 OK Date: Wed, 1 Jun 2011 20:05:13 GMT Server: HTTP Server Last-Modified: Mon, 06 Aug 2009 01:02:23 GMT Accept-Ranges: bytes Connection: Close Content-Type: audio/mpeg CLIENT: HEAD /stream.mpeg HTTP/1.0 Host: 127.0.0.1 User-Agent: SuperPlayer Connection: Close SERVER: HTTP/1.0 200 OK Date: Wed, 1 Jun 2011 20:05:13 GMT Server: HTTP Server Last-Modified: Mon, 06 Aug 2009 01:02:23 GMT Accept-Ranges: bytes Connection: Close Content-Type: audio/mpeg 231489172304981723409817234981234acvass123412323 21312hjdfaoi8w34yorhadl4hi8rali45mhalo3i,wmotw 345fqw354aoicu43yocq2i3hr
客户端/ ApacheServer通信:
CLIENT: GET /test.mp3 HTTP/1.0 Host: 192.168.1.120 User-Agent: SuperPlayer Connection: Close SERVER: HTTP/1.1 200 OK Date: Wed, 01 Jun 2011 19:15:11 GMT Server: Apache/2.2.16 (Win32) Last-Modified: Thu, 29 Apr 2010 21:06:34 GMT ETag: "14000000047049-4f75c8-4856680636a80" Accept-Ranges: bytes Content-Length: 5207496 Connection: close Content-Type: audio/mpeg ...d.....<).0.. ..........<.@.. ( .h.$.J...1...i....A. ......c....a.9..!g.N...A. ........ ....>......|.......8....a......|..|N.............'>........?...C.....@..TJt.n .e...r.iL..#..IH...pR|.是关闭套接字是正确的行动.如果客户端正确使用此标头,则一旦收到您的响应,它们就会关闭它们的套接字.
我在这里注意到的是你的服务器没有返回Content-Length标头.即使客户端发出HEAD请求,based on the W3C proposal (sec. 9.4):
The metainformation contained in the HTTP
headers in response to a HEAD request
SHOULD be identical to the information
sent in response to a GET request.
This method can be used for obtaining
metainformation about the entity
implied by the request without
transferring the entity-body itself.
This method is often used for testing
hypertext links for validity,
accessibility, and recent
modification.The response to a HEAD request MAY be
cacheable in the sense that the
information contained in the response
MAY be used to update a previously
cached entity from that resource. If
the new field values indicate that the
cached entity differs from the current
entity (as would be indicated by a
change in Content-Length, Content-MD5,
ETag or Last-Modified), then the cache
MUST treat the cache entry as stale.
这里的关键是确保在不实际发送数据的情况下告诉客户端响应的大小.