Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 67545 invoked from network); 8 Dec 2008 08:13:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Dec 2008 08:13:18 -0000 Received: (qmail 22623 invoked by uid 500); 8 Dec 2008 08:13:31 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 22603 invoked by uid 500); 8 Dec 2008 08:13:31 -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 22594 invoked by uid 99); 8 Dec 2008 08:13:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Dec 2008 00:13:31 -0800 X-ASF-Spam-Status: No, hits=-1997.6 required=10.0 tests=ALL_TRUSTED,NORMAL_HTTP_TO_IP,URIBL_RHS_DOB,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Dec 2008 08:11:59 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A02D6234C32B for ; Mon, 8 Dec 2008 00:12:48 -0800 (PST) Message-ID: <2082763756.1228723968655.JavaMail.jira@brutus> Date: Mon, 8 Dec 2008 00:12:48 -0800 (PST) From: "Kevin Zhou (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-6036) [classlib] [luni] HttpURLConnection does not have the "Accept" header In-Reply-To: <160765473.1228722884296.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-6036?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12654345#action_12654345 ] Kevin Zhou commented on HARMONY-6036: ------------------------------------- I investigated this problem and found that "Accept" property should be added in org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.createRequest() method. >From HTTP/1.1 specification, "If no Accept header field is present, then it is assumed that the client accepts all media types". if (reqHeader.get("Accept") == null) { //$NON-NLS-1$ output.append("Accept: "text/html, image/gif, image/jpeg, *; "q=.2, */*; q=.2\r\n"); //$NON-NLS-1$ } > [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 > > Original Estimate: 24h > Remaining Estimate: 24h > > 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.