@Test public void testUrl() { HttpRequest httpRequest = new HttpRequest(); httpRequest.set("GET http://jodd.org:173/index.html?light=true"); assertEquals("http://jodd.org:173/index.html?light=true", httpRequest.url()); }
@Test public void testSet() { HttpRequest httpRequest = new HttpRequest(); httpRequest.set("GET http://jodd.org:173/index.html?light=true"); assertEquals("GET", httpRequest.method()); assertEquals("http", httpRequest.protocol()); assertEquals("jodd.org", httpRequest.host()); assertEquals(173, httpRequest.port()); assertEquals("/index.html", httpRequest.path()); assertEquals("true", httpRequest.query().get("light")[0]); httpRequest = new HttpRequest(); httpRequest.set("http://jodd.org:173/index.html?light=true"); assertEquals("GET", httpRequest.method()); assertEquals("http", httpRequest.protocol()); assertEquals("jodd.org", httpRequest.host()); assertEquals(173, httpRequest.port()); assertEquals("/index.html", httpRequest.path()); assertEquals("true", httpRequest.query().get("light")[0]); httpRequest = new HttpRequest(); httpRequest.set("jodd.org:173/index.html?light=true"); assertEquals("GET", httpRequest.method()); assertEquals("http", httpRequest.protocol()); assertEquals("jodd.org", httpRequest.host()); assertEquals(173, httpRequest.port()); assertEquals("/index.html", httpRequest.path()); assertEquals("true", httpRequest.query().get("light")[0]); httpRequest = new HttpRequest(); httpRequest.set("jodd.org/index.html?light=true"); assertEquals("GET", httpRequest.method()); assertEquals("http", httpRequest.protocol()); assertEquals("jodd.org", httpRequest.host()); assertEquals(80, httpRequest.port()); assertEquals("/index.html", httpRequest.path()); assertEquals("true", httpRequest.query().get("light")[0]); httpRequest = new HttpRequest(); httpRequest.set("/index.html?light=true"); assertEquals("GET", httpRequest.method()); assertEquals("http", httpRequest.protocol()); assertEquals("localhost", httpRequest.host()); assertEquals(80, httpRequest.port()); assertEquals("/index.html", httpRequest.path()); assertEquals("true", httpRequest.query().get("light")[0]); httpRequest = new HttpRequest(); httpRequest.set("http://jodd.org"); assertEquals("GET", httpRequest.method()); assertEquals("http", httpRequest.protocol()); assertEquals("jodd.org", httpRequest.host()); assertEquals(80, httpRequest.port()); assertEquals("/", httpRequest.path()); }