harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Hindess (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6521) [classlib][luni] HttpURLConnection.getResponseCode() hangs on incomplete chunked response
Date Mon, 24 May 2010 12:08:24 GMT
[classlib][luni] HttpURLConnection.getResponseCode() hangs on incomplete chunked response

                 Key: HARMONY-6521
                 URL: https://issues.apache.org/jira/browse/HARMONY-6521
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 6.0M2, 5.0M14
            Reporter: Mark Hindess
             Fix For: 6.0M3, 5.0M15

HttpURLConnection.getResponseCode() hangs when reading chunked responses because it eagerly
tries to find the size of the first chunk.  It should read the chunk size lazily.  The RI
doesn't hang.

import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.ServerSocket;
import java.net.URL;

public class HUCHang {
    public static void main(String[] args) throws Exception {
        ServerSocket server = new ServerSocket(0);
        URL u = new URL("http://"
                        + server.getInetAddress().getHostAddress()
                        + ":" + server.getLocalPort());
        HttpURLConnection uc = (HttpURLConnection)u.openConnection();
        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"
            +"a"; // intentionally incomplete chunk size line
        System.err.print("response code = \"");
        System.err.println(+ uc.getResponseCode() + "\"");

Given that chunked responses are often used for (slow) streamed responses then matching behaviour
makes sense.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message