Sign in to follow this  

How to implement 206 partial content?

Recommended Posts


I have a tiny http server and I would like to serve GET requests for large files with partial content. My problem is, What should be headers I add to response to make client make partial requests. As far as I have red, you can only inform the client that you accept partial request with :

Accepet-Ranges: bytes

header. But the client acts ignoring it and makes standard 200 request, so that if I close connection sending no content to the client, no other request is fired on my server. If I get a request for a large file I send only header portion and no content. This is the header portion I send:

HTTP/1.1 200 OK
Accept-Ranges: bytes
Date: Fri, 27 Apr 2012 14:56:08 GMT
ETag: "cc718c-5217-439cf1c245800"
Content-Length: 97240519
Content-Type: application/octet-stream
Connection: Close

I then close the connection, sending no content. This seems to not work and I cannot find out how to make the browsers fire request with Range header on me. I do not understand technique, How do I respond? I send no content or only part after the initial request?

Share this post

Link to post
Share on other sites
You don't "force" the client to do anything in server programming, ever.

You must always assume, in any client/server protocol, that clients are free to do whatever the hell they want with your connection, and react appropriately. If your client supports ranged requests and knows enough to make them, it will make them; if it doesn't, there is no magic you can do on your server to change that.

Share this post

Link to post
Share on other sites
thanks for the answer.

But still, modern browsers support this feature, and I can't seem to find this certain behaviour on my side after which browsers partialy request content.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this