HttpRequest { public Map<String, Collection<String>> parameters() { return Collections.unmodifiableMap(this.parms); } HttpRequest(@NotNull final Socket socket); Map<String, Collection<String>> headers(); Map<String, Collection<String>> parameters(); URI requestUri(); String method(); Range range();  }
@Test public void fetchesQueryParams() throws Exception { final HttpRequest request = HttpRequestMocker.toRequest( "GET /test.html?test=param&hello=world HTTP/1.1\nHost:local\nAccept:text/plain\n\nbody" ); MatcherAssert.assertThat( request.parameters().get("test"), Matchers.hasItem("param") ); MatcherAssert.assertThat( request.parameters().get("hello"), Matchers.hasItem("world") ); }
@Test public void fetchesDuplicateQueryParams() throws Exception { final HttpRequest request = HttpRequestMocker.toRequest( "GET /test.html?first=one&second=two&first=three HTTP/1.1\nHost:local\nAccept:text/plain\n\nbody" ); MatcherAssert.assertThat( request.parameters().get("first"), Matchers.allOf( Matchers.<String>iterableWithSize(2), Matchers.hasItems("one", "three") ) ); MatcherAssert.assertThat( request.parameters().get("second"), Matchers.hasItem("two") ); }
@Test public void fetchesQueryParamsWithNoValue() throws Exception { final HttpRequest request = HttpRequestMocker.toRequest( "GET /test.html?blank&something=yes&nothing HTTP/1.1\nHost:local\nAccept:text/plain\n\nbody" ); MatcherAssert.assertThat( request.parameters().get("blank"), Matchers.hasItem("") ); MatcherAssert.assertThat( request.parameters().get("something"), Matchers.hasItem("yes") ); MatcherAssert.assertThat( request.parameters().get("nothing"), Matchers.hasItem("") ); }