jersey
  1. jersey
  2. JERSEY-2164

Multi value http headers are not correctly read by the server

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5
    • Component/s: containers
    • Labels:
      None

      Description

      Such a Http header

      hello: world, universe
      

      Will be read as "hello" > ["world, universe"] and not "hello">["world", "universe"]. So, the resource method:

      @Path("resource")
          public static class MyResource {
              @GET
              public String get(@HeaderParam("hello") List<String> headers) {
                  return headers.size() + ":" + headers;
              }
          }
      

      will return 1:[world, universe]. This test will fail:

      @Test
          public void test() {
              Response response = target().path("resource").request()
                      .header("hello", "world").header("hello", "universe").get();
              assertEquals(200, response.getStatus());
              assertEquals("2:[world, universe]", response.readEntity(String.class));
          }
      

      org.junit.ComparisonFailure:
      Expected :2:[world, universe]
      Actual :1:[world, universe]

        Issue Links

          Activity

          Hide
          Miroslav Fuksa added a comment -

          see tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderParamTest.java when fixing this issue. Unignore the test.

          Show
          Miroslav Fuksa added a comment - see tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderParamTest.java when fixing this issue. Unignore the test.
          Hide
          Michal Gajdos added a comment -

          Issue is that HTTP spec says that multiple headers can be merged into one using comma as separator but it doesn't say that the resulting value can be split using the same way. See [1].

          [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

          Show
          Michal Gajdos added a comment - Issue is that HTTP spec says that multiple headers can be merged into one using comma as separator but it doesn't say that the resulting value can be split using the same way. See [1] . [1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

            People

            • Assignee:
              Michal Gajdos
              Reporter:
              Miroslav Fuksa
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours
                3h