Skip to content

Instantly share code, notes, and snippets.

@nicokruger
Created May 17, 2012 18:12
Show Gist options
  • Save nicokruger/2720635 to your computer and use it in GitHub Desktop.
Save nicokruger/2720635 to your computer and use it in GitHub Desktop.
canned-http-router.java
public void testHeaders() throws Exception {
router.on("/testHeaders").put(new F<Request, Response> () {
@Override
public Response f(Request a) {
System.out.println(a.headers.keySet());
Assert.assertEquals("application/json; charset=UTF8", a.headers.get("Content-Type"));
Assert.assertEquals("MyUserAgent", a.headers.get("User-Agent"));
Assert.assertTrue("Check authentication is http basic auth", a.headers.get("Authorization").contains("Basic "));
return Response.custom(200, Maps.<String,String>newHashMap(), "<html>Custom response content</html>");
});
Response r = httpPost("http://localhost:8080/testHeaders");
Assert.assertEquals(200, r.responseCode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment