Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 83319 invoked from network); 3 Sep 2010 11:04:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Sep 2010 11:04:01 -0000 Received: (qmail 92558 invoked by uid 500); 3 Sep 2010 11:04:01 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 92474 invoked by uid 500); 3 Sep 2010 11:03:59 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 92351 invoked by uid 99); 3 Sep 2010 11:03:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Sep 2010 11:03:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Sep 2010 11:03:57 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o83B3aCM017887 for ; Fri, 3 Sep 2010 11:03:36 GMT Message-ID: <27824280.9301283511816888.JavaMail.jira@thor> Date: Fri, 3 Sep 2010 07:03:36 -0400 (EDT) From: "Tim Ellison (JIRA)" To: commits@harmony.apache.org Subject: [jira] Updated: (HARMONY-6522) [classlib][luni] HttpURLConnection returns unread data from previous chunked response In-Reply-To: <22778025.17671274732186259.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HARMONY-6522?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Tim Ellison updated HARMONY-6522: --------------------------------- Fix Version/s: (was: 5.0M15) (was: 6.0M3) > [classlib][luni] HttpURLConnection returns unread data from previous chunked response > ------------------------------------------------------------------------------------- > > Key: HARMONY-6522 > URL: https://issues.apache.org/jira/browse/HARMONY-6522 > Project: Harmony > Issue Type: Bug > Components: Classlib > Affects Versions: 6.0M2, 5.0M14 > Reporter: Mark Hindess > > Harmony's HttpURLConnection implementation supports persistent connections. However, with chunked responses if the client ignores some chunks they are returned during reads of subsequent requests. Here is a reproducer: > import java.io.BufferedReader; > import java.io.InputStreamReader; > import java.io.OutputStream; > import java.net.HttpURLConnection; > import java.net.ServerSocket; > import java.net.URL; > public class TruncatedChunk { > public static void main(String[] args) throws Exception { > final ServerSocket server = new ServerSocket(0); > URL u = new URL("http://" > + server.getInetAddress().getHostAddress() > + ":" + server.getLocalPort()); > HttpURLConnection uc = (HttpURLConnection)u.openConnection(); > System.err.println("uc = " + uc); > uc.connect(); > OutputStream cos = server.accept().getOutputStream(); > String resp = > "HTTP/1.1 200 OK\r\n" > +"Content-Type: text/plain\r\n" > +"Transfer-Encoding: chunked\r\n" > +"\r\n" > +"8; ignore me\r\n" > +"FIRST!\r\n\r\n"; > cos.write(resp.getBytes()); > BufferedReader bis = > new BufferedReader(new InputStreamReader(uc.getInputStream())); > System.err.print("read line: "); > System.err.println(bis.readLine()); > // nothing should read this because this buffer reader is closed > // when it is re-opened this should have been skipped > resp = "9\r\nSECOND!\r\n\r\n"; > cos.write(resp.getBytes()); > System.err.println("closing"); > bis.close(); > System.err.println("opening"); > uc = (HttpURLConnection)u.openConnection(); > // RI doesn't use connection pool so it should hang here waiting for > // server to accept > System.err.println("getting input stream"); > bis = new BufferedReader(new InputStreamReader(uc.getInputStream())); > System.err.print("read line: "); > // harmony uses connection pool so it should hang here waiting for > // request headers? > System.err.println(bis.readLine()); > } > } > The line SECOND should not be seen since it is part of the response to the first request but it is written after the last read by the client which subsequently closes the input stream reader. However, when the connection is re-used the subsequent request sees this chunk as it's first read where as it should hang waiting for the response from the server. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.