Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6036

[classlib] [luni] HttpURLConnection does not have the "Accept" header

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.0M8
    • 5.0M9
    • Classlib
    • None
    • Moderate

    Description

      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()); }

      }

      Attachments

        1. HARMONY-6036.diff
          7 kB
          Kevin Zhou

        Activity

          People

            qiuxiaox Sean Qiu
            zhoukevin Kevin Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified