views:

246

answers:

2

Hi

I have been trying to stream audio from a particular point by using the Range header values but I always get the song right from the beginning. I am doing this through a program so am not sure whether the problem lies in my code or on the server.

How can I find out whether the server supports the Range header param?

Thanks.

+1  A: 

One way is just to try, and check the response. In your case, it appears the server doesn't support ranges.

Alternatively, do a GET or HEAD on the URI, and check for the Accept-Ranges response header.

Julian Reschke
+1  A: 

The way the HTTP spec defines it, if the server knows how to support the Range header, it will. That in turn, requires it to return a 206 Partial Content response code with a Content-Range header, when it returns content to you. Otherwise, it will simply ignore the Content-Range header in your request, and return a 200 response code.

This might seem silly, but are you sure you're crafting a valid HTTP request header? All too commonly, I forget to specify HTTP/1.1 in the request, or forget to specify the Range specifier, such as "bytes".

Oh, and if all you want to do is check, then just send a HEAD request instead of a GET request. Same headers, same everything, just "HEAD" instead of "GET". If you receive a 206 response, you'll know Range is supported, and otherwise you'll get a 200 response.

scraimer