HTTP Header Settings in Java 6 SE httpserver

I am trying to publish an Atom feed (generated in Rome) using Java 6 SE httpserver. For proper feed detection in FireFox, I need custom headers.

This is my code:

Headers headers=e.getRequestHeaders(); ArrayList<String>list=new ArrayList<String>(); list.add("application/atom+xml"); headers.put("content-type", list); e.sendResponseHeaders(200, 0); 

Unfortunately, the channel is displayed as xml (the browser does not ask me what to do with the feed), and sniffing with livehttpheaders shows that the content type attribute is missing.

+6
source share
1 answer

You can customize the response headers as follows:

 Headers headers = exchange.getResponseHeaders(); headers.add("Content-Type", "application/atom+xml"); exchange.sendResponseHeaders(200, 0); 
+12
source

All Articles