开发者

Settings http headers in Java 6 SE httpserver

开发者 https://www.devze.com 2022-12-12 20:10 出处:网络
I try to publish Atom feed (generated with Rome) using Java 6 SE httpserver. For correct feed discovery in FireFox I need custom headers.

I try to publish Atom feed (generated with Rome) using Java 6 SE httpserver. For correct feed discovery in FireFox I need custom headers.

This开发者_StackOverflow 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 feed is displaying like xml (browser doesn't, ask me what to do with feed) and sniffing with livehttpheaders shows that there isn't content-type attribute.


You can set the response headers like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消