1f29e141959a4bbb738453c3462518e52ebb218cePaul Hawkepackage fi.iki.elonen;
2f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
38b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie/*
48b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * #%L
58b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * NanoHttpd-Core
68b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * %%
78b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * Copyright (C) 2012 - 2015 nanohttpd
88b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * %%
98b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * Redistribution and use in source and binary forms, with or without modification,
108b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * are permitted provided that the following conditions are met:
119e1ec7bff40d70d31953a04dd448665aaf549395ritchie *
128b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * 1. Redistributions of source code must retain the above copyright notice, this
138b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie *    list of conditions and the following disclaimer.
149e1ec7bff40d70d31953a04dd448665aaf549395ritchie *
158b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * 2. Redistributions in binary form must reproduce the above copyright notice,
168b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie *    this list of conditions and the following disclaimer in the documentation
178b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie *    and/or other materials provided with the distribution.
189e1ec7bff40d70d31953a04dd448665aaf549395ritchie *
198b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * 3. Neither the name of the nanohttpd nor the names of its contributors
208b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie *    may be used to endorse or promote products derived from this software without
218b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie *    specific prior written permission.
229e1ec7bff40d70d31953a04dd448665aaf549395ritchie *
238b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
248b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
258b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
268b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
278b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
288b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
298b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
308b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
318b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
328b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * OF THE POSSIBILITY OF SUCH DAMAGE.
338b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie * #L%
348b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie */
358b3f33ce61812b29a5cacd1e7e6d350b40531f9britchie
365e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchieimport static junit.framework.Assert.assertEquals;
375e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchieimport static junit.framework.Assert.assertNotNull;
385e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchieimport static junit.framework.Assert.assertTrue;
39f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
40f29e141959a4bbb738453c3462518e52ebb218cePaul Hawkeimport java.io.ByteArrayOutputStream;
41f29e141959a4bbb738453c3462518e52ebb218cePaul Hawkeimport java.util.List;
42f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
435e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchieimport org.junit.Test;
44f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
45f29e141959a4bbb738453c3462518e52ebb218cePaul Hawkepublic class HttpGetRequestTest extends HttpServerTest {
46f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
47f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
485e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testDecodingFieldWithEmptyValueAndFieldWithMissingValueGiveDifferentResults() {
495e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo&bar= HTTP/1.1");
505e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("foo") instanceof List);
515e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(0, this.testServer.decodedParamters.get("foo").size());
525e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("bar") instanceof List);
535e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(1, this.testServer.decodedParamters.get("bar").size());
545e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("", this.testServer.decodedParamters.get("bar").get(0));
55f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
56f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
57f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
585e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testDecodingMixtureOfParameters() {
595e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo=bar&foo=baz&zot&zim= HTTP/1.1");
605e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("foo") instanceof List);
615e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(2, this.testServer.decodedParamters.get("foo").size());
625e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("bar", this.testServer.decodedParamters.get("foo").get(0));
635e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("baz", this.testServer.decodedParamters.get("foo").get(1));
645e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("zot") instanceof List);
655e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(0, this.testServer.decodedParamters.get("zot").size());
665e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("zim") instanceof List);
675e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(1, this.testServer.decodedParamters.get("zim").size());
685e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("", this.testServer.decodedParamters.get("zim").get(0));
695e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    }
70b814145cf66e94b7ce5511077ca0ebcff6e67268Paul Hawke
715e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    @Test
725e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testDecodingParametersFromParameterMap() {
735e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo=bar&foo=baz&zot&zim= HTTP/1.1");
745e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(this.testServer.decodedParamters, this.testServer.decodedParamtersFromParameter);
75b814145cf66e94b7ce5511077ca0ebcff6e67268Paul Hawke    }
76b814145cf66e94b7ce5511077ca0ebcff6e67268Paul Hawke
775e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    // --------------------------------------------------------------------------------------------------------
785e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    // //
795e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie
80b814145cf66e94b7ce5511077ca0ebcff6e67268Paul Hawke    @Test
815e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testDecodingParametersWithSingleValue() {
825e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo=bar&baz=zot HTTP/1.1");
835e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("foo=bar&baz=zot", this.testServer.queryParameterString);
845e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("foo") instanceof List);
855e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(1, this.testServer.decodedParamters.get("foo").size());
865e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("bar", this.testServer.decodedParamters.get("foo").get(0));
875e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("baz") instanceof List);
885e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(1, this.testServer.decodedParamters.get("baz").size());
895e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("zot", this.testServer.decodedParamters.get("baz").get(0));
90f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
91f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
92f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
935e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testDecodingParametersWithSingleValueAndMissingValue() {
945e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo&baz=zot HTTP/1.1");
955e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("foo&baz=zot", this.testServer.queryParameterString);
965e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("foo") instanceof List);
975e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(0, this.testServer.decodedParamters.get("foo").size());
985e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("baz") instanceof List);
995e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(1, this.testServer.decodedParamters.get("baz").size());
1005e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("zot", this.testServer.decodedParamters.get("baz").get(0));
101f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
102f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
103f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
1045e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testDecodingSingleFieldRepeated() {
1055e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo=bar&foo=baz HTTP/1.1");
1065e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertTrue(this.testServer.decodedParamters.get("foo") instanceof List);
1075e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(2, this.testServer.decodedParamters.get("foo").size());
1085e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("bar", this.testServer.decodedParamters.get("foo").get(0));
1095e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("baz", this.testServer.decodedParamters.get("foo").get(1));
110f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
111f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
112f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
1135e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testEmptyHeadersSuppliedToServeMethodFromSimpleWorkingGetRequest() {
1145e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + " HTTP/1.1");
1155e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertNotNull(this.testServer.parms);
1165e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertNotNull(this.testServer.header);
1175e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertNotNull(this.testServer.files);
1185e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertNotNull(this.testServer.uri);
119f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
120f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
121f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
1225e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testFullyQualifiedWorkingGetRequest() throws Exception {
1235e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        ByteArrayOutputStream outputStream = invokeServer("GET " + HttpServerTest.URI + " HTTP/1.1");
1245e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie
1255e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        String[] expected = {
1265e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "HTTP/1.1 200 OK",
1275e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "Content-Type: text/html",
1285e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "Date: .*",
1295e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "Connection: keep-alive",
1305e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "Content-Length: 0",
1315e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            ""
1325e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        };
1335e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie
1345e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertResponse(outputStream, expected);
135f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
136f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
137f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
138f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    public void testMultipleGetParameters() {
1395e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo=bar&baz=zot HTTP/1.1");
1405e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("bar", this.testServer.parms.get("foo"));
1415e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("zot", this.testServer.parms.get("baz"));
142f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
143f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
144f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
145f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    public void testMultipleGetParametersWithMissingValue() {
1465e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo=&baz=zot HTTP/1.1");
1475e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("", this.testServer.parms.get("foo"));
1485e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("zot", this.testServer.parms.get("baz"));
149f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
150f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
151f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
152f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    public void testMultipleGetParametersWithMissingValueAndRequestHeaders() {
1535e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo=&baz=zot HTTP/1.1\nAccept: text/html");
1545e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("", this.testServer.parms.get("foo"));
1555e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("zot", this.testServer.parms.get("baz"));
1565e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("text/html", this.testServer.header.get("accept"));
157f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
158f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
159f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
1605e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testMultipleHeaderSuppliedToServeMethodFromSimpleWorkingGetRequest() {
1615e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        String userAgent = "jUnit 4.8.2 Unit Test";
1625e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        String accept = "text/html";
1635e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + " HTTP/1.1\nUser-Agent: " + userAgent + "\nAccept: " + accept);
1645e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(userAgent, this.testServer.header.get("user-agent"));
1655e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(accept, this.testServer.header.get("accept"));
166f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
167f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
168f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
1695e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testOutputOfServeSentBackToClient() throws Exception {
1705e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        String responseBody = "Success!";
171504cf71fb77ee34a9b37a632664c58f89ab1984eJarno Elonen        this.testServer.response = NanoHTTPD.newFixedLengthResponse(responseBody);
1725e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        ByteArrayOutputStream outputStream = invokeServer("GET " + HttpServerTest.URI + " HTTP/1.1");
173f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
1745e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        String[] expected = {
1755e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "HTTP/1.1 200 OK",
1765e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "Content-Type: text/html",
1775e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "Date: .*",
1785e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "Connection: keep-alive",
1795e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "Content-Length: 8",
1805e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            "",
1815e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie            responseBody
1825e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        };
1835e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie
1845e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertResponse(outputStream, expected);
185f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
186f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
187f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
1885e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testSingleGetParameter() {
1895e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo=bar HTTP/1.1");
1905e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("bar", this.testServer.parms.get("foo"));
191f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
192f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
193f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
1945e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testSingleGetParameterWithNoValue() {
1955e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + "?foo HTTP/1.1");
1965e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals("", this.testServer.parms.get("foo"));
197f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
198f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
199f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    @Test
2005e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie    public void testSingleUserAgentHeaderSuppliedToServeMethodFromSimpleWorkingGetRequest() {
2015e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        String userAgent = "jUnit 4.8.2 Unit Test";
2025e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        invokeServer("GET " + HttpServerTest.URI + " HTTP/1.1\nUser-Agent: " + userAgent + "\n");
2035e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(userAgent, this.testServer.header.get("user-agent"));
2045e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(NanoHTTPD.Method.GET, this.testServer.method);
2055e2e2f19e06b9f4a01c6da83a2297eb18fe2b546ritchie        assertEquals(HttpServerTest.URI, this.testServer.uri);
206f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke    }
207f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke
208f29e141959a4bbb738453c3462518e52ebb218cePaul Hawke}
209