服务器
Class MyService{
@Context
private HttpServletResponse httpResponse;
@POST
@Consumes({"application/json"})
@Produces({"application/json"})
public String handlePostRequest(Object resource) {
httpResponse.addHeader("X-Origin", resPrim.getFrom());
httpResponse.addHeader("X-RI", resPrim.getRequestIdentifier());
httpResponse.addHeader("X-RET", resPrim.getResultExpirationTimestamp());
httpResponse.setStatus(getHttpStatusCode());
return "DUMMY";
}
客户端:
HttpResponse httpResponse = httpclient.execute(httpUriRequest);
System.out.println("RESPONSE_STATUS_CODE: " + httpResponse.getStatusLine().getStatusCode());
for (Header h: httpResponse.getAllHeaders()) {
//Do your stuff here
System.out.println("HEADER" + h);
}
当我在客户端打印标题时,SOP显示:
HEADER Server: Apache-Coyote/1.1
HEADER Content-Type: application/json
HEADER Content-Length: 4
HEADER Date: Tue, 24 Nov 2015 08:33:53 GMT
我的回复标题是否未被添加?
我想获取我在服务器上设置的自定义标题,但响应只有上面的4个标题。
如何获取自定义标头?