harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Zhou (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-6036) [classlib] [luni] HttpURLConnection does not have the "Accept" header
Date Mon, 08 Dec 2008 07:54:44 GMT
[classlib] [luni] HttpURLConnection does not have the "Accept" header
---------------------------------------------------------------------

                 Key: HARMONY-6036
                 URL: https://issues.apache.org/jira/browse/HARMONY-6036
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M8
            Reporter: Kevin Zhou
             Fix For: 5.0M9


Start server [1], conduct HeaderTest [2] on HARMONY and RI.
They prints out the following headers.  Thereinto, RI has the "Accept"  header, while HARMONY
doesn't. 

On RI:
GET / HTTP/1.1
User-Agent: Java/1.6.0_07
Host: 127.0.0.1:8030
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

On HARMONY:
GET / HTTP/1.1
User-Agent: Java/1.6.0_07
Host: 127.0.0.1:8030
Connection: keep-alive



[1] Server
public class MockServer {
    public static void main(String[] args) {
        MockServer server = new MockServer();
        server.await();
    }
    public void await() {
        ServerSocket serverSocket = null;
        int port = 8030;
        try {
            serverSocket = new ServerSocket(port, 1, InetAddress
                    .getByName("127.0.0.1"));
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
        // Loop waiting for a request
        while (true) {
            Socket socket = null;
            InputStream input = null;
            OutputStream output = null;
            try {
                socket = serverSocket.accept();
                input = socket.getInputStream();
                output = socket.getOutputStream();

                Scanner in = new Scanner(input);
                PrintWriter out = new PrintWriter(output, true);
                while (in.hasNextLine()) {
                    String line = in.nextLine();
                    System.out.println(line);
                }
                // Close the socket
                socket.close();
                // check if the previous URI is a shutdown command
            } catch (IOException e) {
                e.printStackTrace();
                continue;
            }
        }
    }
}

[2] HeaderTest
public class HeaderTest {
    public static void main(String[] args) throws IOException {
        URL url = new URL("http://127.0.0.1:8030");
        URLConnection conn = url.openConnection();
        conn.connect();
        System.out.println(conn.getLastModified());
    }
}

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