Hi,

I'm starting to see more clients making Range requests (iPhone among them)
and I'm trying to understand how much work I have to do to support the
correct behaviour. I've been investigating Tomcat support for this (although
my application will be deployed in different servlet containers; definitely
Tomcat 5.0.x, 5.5.x and Weblogic 9.x currently) and comparing my
expectations with what I'm seeing.

Exhibit A - requesting content, adding a Range: bytes=0-1499 header to the
request.

GET /Protocols/rfc2616/rfc2616-sec14.html HTTP/1.1
Host: www.w3.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11)
Gecko/20071127 Firefox/2.0.0.11
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Range: bytes=0-1499

HTTP/1.x 206 Partial Content
Date: Thu, 13 Dec 2007 10:57:39 GMT
Server: Apache/2
Last-Modified: Wed, 01 Sep 2004 13:24:52 GMT
Etag: "3e3073913b100"
Accept-Ranges: bytes
Content-Length: 1500
Cache-Control: max-age=21600
Expires: Thu, 13 Dec 2007 16:57:39 GMT
P3P: policyref="http://www.w3.org/2001/05/P3P/p3p.xml";
Content-Range: bytes 0-1499/126444
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1



That works as expected, being served by Apache 2, returning a 206 response
with the partial body being returned.

When I request a page via Tomcat locally (requesting the Tomcat user
documentation), I get the following:

Exhibit B - request to Tomcat 5.0.30 ROOT webapp, adding a Range:
bytes=0-1499 header to the request.

GET / HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11)
Gecko/20071127 Firefox/2.0.0.11
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Range: bytes=0-1499

HTTP/1.x 200 OK
Content-Type: text/html;charset=ISO-8859-1
Transfer-Encoding: chunked
Date: Thu, 13 Dec 2007 11:01:23 GMT
Server: Apache-Coyote/1.1

i.e. a 200 response with the full response body.

But as part of the same request, the images are retrieved...

Exhibit C - related image request, adding a Range: bytes=0-1499 header to
the request.

GET /tomcat.gif HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.11)
Gecko/20071127 Firefox/2.0.0.11
Accept: image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8080/
Range: bytes=0-1499

HTTP/1.x 206 Partial Content
Etag: W/"1934-1101296588000"
Last-Modified: Wed, 24 Nov 2004 11:43:08 GMT
Content-Range: bytes 0-1499/1934
Content-Type: image/gif
Content-Length: 1500
Date: Thu, 13 Dec 2007 11:01:23 GMT
Server: Apache-Coyote/1.1

And these have a 206 response, with a partial response body.

I note that the Tomcat 4.0 functional specs talk about Range request support
[1], but not about how to ensure that it's enabled for all resources within
a webapp.

Questions:

1. Why doesn't the page served by the root item get returned as a partial
content response? It is a jsp page in the ROOT webapp, which comes as part
of the tomcat installation.
2. Why do the images react correctly to the Range request?
3. How can I get my resources to respond correctly to the Range request? Am
I missing some configuration thing?

I have a mixture of JSP with Struts 1.2 and Spring MVC. I'm thinking that
I'll need to find or write a Filter to handle this (particularly as it needs
to run on other containers; e.g. Weblogic), but it seems a shame that it
isn't part of the HTTP implementation within the container.

The related headers that I need to consider include Accept-Range, If-Range
and Content-Range. I can take care of setting ETags and Last-Modified
headers for my resources, so I just need to ensure that something is
handling the Range related functionality at some point.

Cheers,

James

[1]
http://tomcat.apache.org/tomcat-4.0-doc/catalina/funcspecs/fs-default.html
-- 
View this message in context: 
http://www.nabble.com/Range-request-header-%28and-related-headers%29-behaviour-tp14314129p14314129.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to