简体   繁体   English

我的Web服务器似乎没有正确回复请求

[英]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. 我在java中开发了一个轻量级的web服务器(非常非常轻),他的目的主要是流式传输音频。

on a webpage i have a simple html5 audio tag. 在网页上我有一个简单的html5音频标签。 When i load the page in a browser the browser make a GET request for the audio file and it's working fine. 当我在浏览器中加载页面时,浏览器会对音频文件发出GET请求并且工作正常。 But when i pause/play or seek , the browser make a request at X bytes with Range condition 但是当我暂停/播放或搜索时,浏览器会在具有范围条件的X字节处发出请求

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: 我做了我的服务器回复206部分内容的条件:

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). 当然下面的二进制数据从360448字节开始,但浏览器似乎并不喜欢它,当我在浏览器上观看网络数据时,它甚至没有得到回复(连接被标记为已取消) 。

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. 我试着看看apache服务器发生了什么,但这有点难,因为浏览器总是使用200(缓存),这意味着它使用mp3的缓存版本,所以没有请求服务器。

I tried cheating and using another response number like 200 or even 304 (some server seem to use it) but no luck here. 我试过作弊并使用另一个响应号码,如200甚至304(某些服务器似乎使用它),但这里没有运气。

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 根据http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16 ,标题应该是

Content-Range: bytes 360448-11487361/11487362

11487362 being the full size of the file, with 11487361 being the last 0-based byte offset. 11487362是文件的完整大小, 11487361是最后一个基于0的字节偏移量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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