Harmony
  1. Harmony
  2. HARMONY-6561

[classlib][luni]HttpConnection should not throw a IOException if the server return 401 but does not provide a WWW-Authenticate header.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.0M15
    • Component/s: None
    • Labels:
      None
    • Environment:
      All
    • Patch Info:
      Patch Available

      Description

      When the server return a 401(UNAUTHORIZED), it supposed to provide a "WWW-Authenticate" header. But if it is not provided, we should not throw a IOException. See the details in testcase.

      1. HARMONY-6561.diff
        8 kB
        Li Jing Qin
      2. HARMONY-6561.v2.diff
        8 kB
        Li Jing Qin
      3. HARMONY-6561.v3.diff
        7 kB
        Li Jing Qin

        Activity

        Li Jing Qin made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        Li Jing Qin added a comment -

        Verified. Thanks Mark.

        Show
        Li Jing Qin added a comment - Verified. Thanks Mark.
        Hide
        Hudson added a comment -

        Integrated in Harmony-select-1.5-head-linux-x86_64 #51 (See http://hudson.zones.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/51/)
        Applying modified version of the most recent patch from "HARMONY-6561
        [classlib][luni]HttpConnection should not throw a IOException if the
        server return 401 but does not provide a WWW-Authenticate header".

        I moved the additional jetty classpath entries from the top-level build file
        to the luni module which needs them.

        Show
        Hudson added a comment - Integrated in Harmony-select-1.5-head-linux-x86_64 #51 (See http://hudson.zones.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/51/ ) Applying modified version of the most recent patch from " HARMONY-6561 [classlib] [luni] HttpConnection should not throw a IOException if the server return 401 but does not provide a WWW-Authenticate header". I moved the additional jetty classpath entries from the top-level build file to the luni module which needs them.
        Hide
        Hudson added a comment -

        Integrated in Harmony-1.5-head-linux-x86_64 #875 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/875/)
        Applying modified version of the most recent patch from "HARMONY-6561
        [classlib][luni]HttpConnection should not throw a IOException if the
        server return 401 but does not provide a WWW-Authenticate header".

        I moved the additional jetty classpath entries from the top-level build file
        to the luni module which needs them.

        Show
        Hudson added a comment - Integrated in Harmony-1.5-head-linux-x86_64 #875 (See http://hudson.zones.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/875/ ) Applying modified version of the most recent patch from " HARMONY-6561 [classlib] [luni] HttpConnection should not throw a IOException if the server return 401 but does not provide a WWW-Authenticate header". I moved the additional jetty classpath entries from the top-level build file to the luni module which needs them.
        Mark Hindess made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 5.0M15 [ 12315054 ]
        Resolution Fixed [ 1 ]
        Hide
        Mark Hindess added a comment -

        I've applied the v3 version of the patch at r959446. I moved the additional jetty classpath
        entries to the luni module rather than adding them to the top level file.

        Please confirm (by closing this jira) that it has been applied as expected.

        Show
        Mark Hindess added a comment - I've applied the v3 version of the patch at r959446. I moved the additional jetty classpath entries to the luni module rather than adding them to the top level file. Please confirm (by closing this jira) that it has been applied as expected.
        Mark Hindess made changes -
        Assignee Mark Hindess [ hindessm ]
        Li Jing Qin made changes -
        Attachment HARMONY-6561.v3.diff [ 12448370 ]
        Hide
        Li Jing Qin added a comment -

        What about the v3?

        Show
        Li Jing Qin added a comment - What about the v3?
        Hide
        Mark Hindess added a comment -

        I wonder if the test might not be quicker if you started one server (rather than three) and just used the request URI to determine the behaviour for the response... i.e. the tests could request:

        http://localhost:port/norealm
        http://localhost:port/realm
        http://localhost:port/realm

        respectively and the handler could return the response (with or without the realm) based on the request URI rather than having separate servers/handler classes?

        Show
        Mark Hindess added a comment - I wonder if the test might not be quicker if you started one server (rather than three) and just used the request URI to determine the behaviour for the response... i.e. the tests could request: http://localhost:port/norealm http://localhost:port/realm http://localhost:port/realm respectively and the handler could return the response (with or without the realm) based on the request URI rather than having separate servers/handler classes?
        Li Jing Qin made changes -
        Attachment HARMONY-6561.v2.diff [ 12448193 ]
        Hide
        Li Jing Qin added a comment -

        Remove the unnecessary prints.

        Show
        Li Jing Qin added a comment - Remove the unnecessary prints.
        Hide
        Li Jing Qin added a comment -

        Agree. The response is complete. I think classlib should give the right to
        user to deal with this situation.

        Sorry about that. It seems I missed the port "println", which is supposed to
        be deleted.


        Yours sincerely,
        Charles Lee

        Show
        Li Jing Qin added a comment - Agree. The response is complete. I think classlib should give the right to user to deal with this situation. Sorry about that. It seems I missed the port "println", which is supposed to be deleted. – Yours sincerely, Charles Lee
        Hide
        Mark Hindess added a comment -

        Looking at the test case, it doesn't seem unreasonable behaviour given that the HTTP request/response has worked correctly. I'd probably only expect an IOException if the response was syntactically invalid/incomplete but in this case the response is complete. The application has visibility of the response code and (lack of) headers so it can decide what to do about it.

        If you threw an IOException then it would be impossible for the application to handle this specific situation (in a legitimate but non-standard way for example) because they'd not be able to distinguish this case from any other.

        Charles, in future, can you remove the println's from the tests before submitting a patch. We try to avoid verbose output from tests. Thanks.

        Show
        Mark Hindess added a comment - Looking at the test case, it doesn't seem unreasonable behaviour given that the HTTP request/response has worked correctly. I'd probably only expect an IOException if the response was syntactically invalid/incomplete but in this case the response is complete. The application has visibility of the response code and (lack of) headers so it can decide what to do about it. If you threw an IOException then it would be impossible for the application to handle this specific situation (in a legitimate but non-standard way for example) because they'd not be able to distinguish this case from any other. Charles, in future, can you remove the println's from the tests before submitting a patch. We try to avoid verbose output from tests. Thanks.
        Hide
        Jesse Wilson added a comment -

        Just curious: why isn't a misbehaving HTTP server worthy of an IOException?

        Show
        Jesse Wilson added a comment - Just curious: why isn't a misbehaving HTTP server worthy of an IOException?
        Li Jing Qin made changes -
        Field Original Value New Value
        Attachment HARMONY-6561.diff [ 12448171 ]
        Hide
        Li Jing Qin added a comment -

        I have change the compile script a bit, because I need jetty things.

        Show
        Li Jing Qin added a comment - I have change the compile script a bit, because I need jetty things.
        Li Jing Qin created issue -

          People

          • Assignee:
            Mark Hindess
            Reporter:
            Li Jing Qin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development