harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-6522) [classlib][luni] HttpURLConnection returns unread data from previous chunked response
Date Fri, 03 Sep 2010 11:03:36 GMT

     [ 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.


Mime
View raw message