Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers");
if (responseHeaders == null)
{
responseHeaders = new Form();
getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
}
responseHeaders.add("X-Some-Header", "the value");
if (responseHeaders == null)
{
responseHeaders = new Form();
getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
}
responseHeaders.add("X-Some-Header", "the value");
本文介绍了如何在HTTP响应中添加自定义头信息,通过使用Restlet框架的Form类实现响应头的设置。
486

被折叠的 条评论
为什么被折叠?



