简体   繁体   中英

My Web server doesn't seem to reply correctly to request

I develop a light web server in java (very very light) , his purpose is mainly to stream audio.

on a webpage i have a simple html5 audio tag. When i load the page in a browser the browser make a GET request for the audio file and it's working fine. But when i pause/play or seek , the browser make a request at X bytes with Range condition

GET /audio/3f6dbbd6adcb5eb4ea4cd981f30a6c409727bbf202367df18d4dd1a91a959fdb HTTP/1.1
Host: localhost:8888
Connection: keep-alive
Accept-Encoding: identity;q=1, *;q=0
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.16 (KHTML, like Gecko) Chrome/24.0.1304.0 Safari/537.16
Accept: */*
Referer: http://localhost:8888/stream/3f6dbbd6adcb5eb4ea4cd981f30a6c409727bbf202367df18d4dd1a91a959fdb
Accept-Language: en-US,en;q=0.8,fr;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Range: bytes=360448-

and i made my sever reply a 206 Partial Content with condition:

HTTP/1.1 206 Partial Content
Date : Wed Nov 07 08:07:32 CET 2012
Content-Length:11126914
Content-Range: bytes 360448-11487361
Accept-Ranges: bytes
Content-Type : audio/mpeg

following of course by the binary data starting at 360448 bytes, but the browser doesn't seem to like it , when i watch the network data on the browser , it doesn't even seem to get the reply (connection is marked as canceled).

I tried to watch what happen with an apache server but thats kind of hard because the browser always use 200 (cache) wich mean it use the cached version of the mp3 so no request to the server.

I tried cheating and using another response number like 200 or even 304 (some server seem to use it) but no luck here.

What do i do wrong in this process ? i can provide more log if it's needed

According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16 , the header should be

Content-Range: bytes 360448-11487361/11487362

11487362 being the full size of the file, with 11487361 being the last 0-based byte offset.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM