Subject: Content-Range question

From: Mihail <[email-masked]>
Date: Tue, 22 Jun 2004 12:28:37 +0300

Hello,

I'm building a webserver as a hobby and I ran into a problem while
sending a file with the Content-Range directive.
I have a 70634 byte file which I transfer to the client in three steps:

HTTP/1.1 206 Partial Content
Date: =)
Server: nifnaf
Last-Modified: =)
Connection: Close
Content-Location: http://localhost:20051/Changes/index.html
Content-Length: 32768
Content-type: text/html
Accept-Ranges: bytes
Content-Range: bytes 0-32767/70634

HTTP/1.1 206 Partial Content
Date: =)
Server: nifnaf
Last-Modified: =)
Connection: Close
Content-Location: http://localhost:20051/Changes/index.html
Content-Length: 32768
Content-type: text/html
Accept-Ranges: bytes
Content-Range: bytes 32768-65535/70634

HTTP/1.1 206 Partial Content
Date: =)
Server: nifnaf
Last-Modified: =)
Connection: Close
Content-Location: http://localhost:20051/Changes/index.html
Content-Length: 5098
Content-type: text/html
Accept-Ranges: bytes
Content-Range: bytes 65536-70633/70634

The problem is that only the first segment (0-32767/70634) is being displayed
in the browser. My question is whether the server has authority to specify Content-Range
without the client's Range request and still hope that the content will be fully recieved?

Thanks,
Mihail

---

From: Jamie Lokier <[email-masked]>
Date: Tue, 22 Jun 2004 12:47:08 +0100

Mihail wrote:
> My question is whether the server has authority to specify
> Content-Range without the client's Range request and still hope that
> the content will be fully recieved?

>From RFC 2616:

   10.2.7 206 Partial Content

      The server has fulfilled the partial GET request for the resource.
      The request MUST have included a Range header field (section 14.35)
      indicating the desired range, and MAY have included an If-Range
      header field (section 14.27) to make the request conditional.

Note the MUST.  If the request doesn't include the Range header, than
you must not issue a 206 response.  This is obvious, as many clients
don't understand Range at all.

-- Jamie

---

From: Mihail <[email-masked]>
Date: Tue, 22 Jun 2004 16:16:49 +0300

Thank you all who replied. I will try to push the file 
through a single 200 response and leave Content-Range as
an afterthought.

Thanks,
Mihail

---

From: Dave Kristol <[email-masked]>
Date: Tue, 22 Jun 2004 09:09:39 -0400 (EDT)

> don't understand Range at all.

Moreover, the server cannot send multiple responses to one request.  It's one 
response per request.  If you (Mihail) want to break up the response into 
smaller chunks, use chunked encoding.

Dave Kristol

---

From: Robert Olofsson <[email-masked]>
Date: Tue, 22 Jun 2004 19:08:05 +0200

Dave Kristol wrote:

> Moreover, the server cannot send multiple responses to one request.  
> It's one response per request.

Well you have the 100 Continue, so in some cases it is valid for the 
server to send multiple responses.
There are some servers that send this for all(?) POSTs made to it.
Probably old systems, I don't remember which server I encountered it on 
so I can not check.

>   If you (Mihail) want to break up the response into smaller chunks, 
> use chunked encoding.

Agree, this is probably what Mihail want to do.

/robo