问题
Trying to stream video to windows media player from a servlet (progressive download style). The streaming works, but I have some weird behavior, which I would like to rule out is not caused by a problem in my implementation.
When using WMP to open an url from the servlet, WMP will perform a total of 4 http-get requests for the same resource, but with slightly different headers each time. The connection for the first 3 requests seems to be closed as soon as the request (including headers) have been sent. The fourth request remains connected, and I can actually deliver response headers and the file content.
Have tried using wireshark to watch the first three requests. Identical starts of responses are sent for all 4 requests, and the first 3 requests managed to send the response headers, and some part of the file content before being closed. (Don't know if its relevant, but have to enable "Support packet-capture from IP TSO-enabled hardware" for wireshark to correctly parse the stream, otherwise the first packet containing the http-response is seen as malformed.)
The 4 request headers below here:
GET /basic/test.mpg HTTP/1.1
Accept: */*
User-Agent: Windows-Media-Player/12.0.7600.16415
Accept-Encoding: gzip, deflate
Host: 192.168.1.34
Connection: Keep-Alive
GET /basic/test.mpg HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Pragma: getIfoFileURI.dlna.org
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
GetContentFeatures.DLNA.ORG: 1
Host: 192.168.1.34
GET /basic/test.mpg HTTP/1.1
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
Icy-Metadata: 1
Accept-Encoding: gzip, deflate
Host: 192.168.1.34
Connection: Keep-Alive
GET /basic/test.mpg HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Pragma: getIfoFileURI.dlna.org
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
GetContentFeatures.DLNA.ORG: 1
Host: 192.168.1.34
Response headers:
HTTP/1.1 200 OK
Content-Type: video/mpeg
Content-Length: 130549760
ETag: TEST1286565215430
ContentFeatures.DLNA.ORG: DLNA.ORG_PN=MPEG_PS_PAL;DLNA.ORG_OP=00
Server: Jetty(6.1.x)
回答1:
The connection for the first 3 requests seems to be closed as soon as the request (including headers) have been sent.
"Seems to be"? I would find out for certain one way or the before proceeding. If it is ending the connection after the response headers are set, it could be that the player was expecting a very specific header to be present. Examples could include Range:
or Cache-Control:
.
来源:https://stackoverflow.com/questions/3893381/stream-video-to-windows-media-player-over-http