Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/6f4c3189369d715974cf to your computer and use it in GitHub Desktop.
Save abhirockzz/6f4c3189369d715974cf to your computer and use it in GitHub Desktop.
Extract Header information by injecting the HttpHeaders interface
@Path("testinject")
public class InjectURIDetails{
//localhost:8080/<root-context>/testinject/httpheaders
@GET
@Path("httpheaders")
public void test(@Context HttpHeaders headers){
System.out.println("ALL headers -- "+ headers.getRequestHeaders().toString());
System.out.println("'Accept' header -- "+ headers.getHeaderString("Accept"));
System.out.println("'TestCookie' value -- "+ headers.getCookies().get("TestCookie").getValue());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment