Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 49446 invoked from network); 13 Apr 2006 10:04:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Apr 2006 10:04:14 -0000 Received: (qmail 86022 invoked by uid 500); 13 Apr 2006 10:04:08 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 85995 invoked by uid 500); 13 Apr 2006 10:04:08 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 85984 invoked by uid 99); 13 Apr 2006 10:04:07 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Apr 2006 03:04:07 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of duncan@oneeyedmen.com designates 69.59.195.20 as permitted sender) Received: from [69.59.195.20] (HELO pyramid-01.kattare.com) (69.59.195.20) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Apr 2006 03:04:07 -0700 Received: from [192.168.1.2] ([81.5.173.244]) (authenticated bits=0) by pyramid-01.kattare.com (8.12.11/8.12.11) with ESMTP id k3DA3i48030297 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) for ; Thu, 13 Apr 2006 03:03:46 -0700 Mime-Version: 1.0 (Apple Message framework v749.3) References: <9135E166-D10C-4710-973A-CCD7B7B7B965@oneeyedmen.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <5D185A3B-C238-427C-A9AA-4643F9053CBB@oneeyedmen.com> Content-Transfer-Encoding: 7bit From: Duncan McGregor Subject: Fwd: If-Range bug in DefaultServlet? Date: Thu, 13 Apr 2006 11:03:39 +0100 To: dev@tomcat.apache.org X-Mailer: Apple Mail (2.749.3) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I've had no response to my last on this subject. I know we're all busy, but this one does seem to be pretty fundamental, and I did go to a bunch of trouble to write the testcase to show the problem ;-) I'd value some feedback - Am I completely wrong in thinking that this is a problem? Is there some issue in the way that I reported it? Duncan McGregor Begin forwarded message: > From: Duncan McGregor > Date: 6 April 2006 00:39:57 BDT > To: dev@tomcat.apache.org > Subject: If-Range bug in DefaultServlet? > > Hi > > I've been making If-Range requests to Tomcat (5.5.16) and it seems > not to be sending back content when the request and current ETags > don't match. > > RFC 2616 section 14.27 says > > If the entity tag given in the If-Range header matches the current > entity tag for the entity, then the server SHOULD provide the > specified sub-range of the entity using a 206 (Partial content) > response. If the entity tag does not match, then the server SHOULD > return the entire entity using a 200 (OK) response. > > Am I doing something wrong, or is the servlet behaviour not as it > SHOULD be? > > Thanks in anticipation > > Duncan McGregor import java.io.IOException; import junit.framework.TestCase; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; import com.enterprisedt.net.ftp.FTPClient; public class TomcatIfRangeTest extends TestCase { protected HttpClient httpClient; protected GetMethod getMethod; private FTPClient ftpClient; @Override public void setUp() throws Exception { httpClient = new HttpClient(); ftpClient = new FTPClient(); ftpClient.setRemoteHost("localhost"); ftpClient.setControlPort(2122); ftpClient.connect(); ftpClient.login("user", "user"); } public void testIfRange() throws Exception { upload("contents", "delme.txt"); assertEquals(HttpStatus.SC_OK, get("http://localhost:8080/ zirisEdge/public/delme.txt")); String etag = headerValue("ETag"); assertEquals("contents", responseBody()); assertEquals(HttpStatus.SC_PARTIAL_CONTENT, get("http://localhost:8080/zirisEdge/public/delme.txt", "If-Range", etag, "Range", "bytes=1-3" )); assertEquals(etag, headerValue("ETag")); assertEquals("ont", responseBody()); upload("new contents", "delme.txt"); assertEquals(HttpStatus.SC_OK, get("http://localhost:8080/zirisEdge/public/delme.txt", "If-Range", etag, "Range", "bytes=1-3" )); assertFalse(etag.equals(headerValue("ETag"))); assertEquals("new contents", responseBody()); // FAILS as responseBody is "" } protected int get(String url, String...headerValues) throws HttpException, IOException { getMethod = new GetMethod(url); for (int i = 0; i < headerValues.length; i += 2) { getMethod.addRequestHeader(headerValues[i], headerValues [i +1]); } return httpClient.executeMethod(getMethod); } protected String responseBody() throws IOException { return getMethod.getResponseBodyAsString(); } protected String headerValue(String headerName) { Header header = getMethod.getResponseHeader(headerName); return header != null ? header.getValue() : null; } protected void upload(String contents, String path) throws Exception { ftpClient.put(contents.getBytes(), path); Thread.sleep(5000); // TODO - is this a cache timeout? } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org