本文整理汇总了Java中javax.servlet.http.HttpServletResponse.getHeaderNames方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.getHeaderNames方法的具体用法?Java HttpServletResponse.getHeaderNames怎么用?Java HttpServletResponse.getHeaderNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.http.HttpServletResponse
的用法示例。
在下文中一共展示了HttpServletResponse.getHeaderNames方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: responseMsgLog
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/** send response message to client */
public static void responseMsgLog(HttpServletResponse response) {
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
System.out.println("Http Post Response: " + response.toString());
/* response status info */
System.out.println("==================STARTLINE==================");
System.out.println("Response Status: " + response.getStatus());
System.out.println("Response ContentType: " + response.getContentType());
/* response header info */
System.out.println("==================HEADER=====================");
Collection<String> headerNames = response.getHeaderNames();
while (!headerNames.isEmpty()) {
String headerName = (String) headerNames.toString();
System.out.println(headerName + ": " + response.getHeader(headerName));
}
System.out.println("===================ENTITY====================");
}
示例2: getResponseHeaders
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
private static Map<String, String> getResponseHeaders(HttpServletResponse response) {
Map<String, String> headers = new LinkedHashMap<>();
for (String header : response.getHeaderNames()) {
String value = response.getHeader(header);
headers.put(header.toLowerCase(), value);
}
headers.remove("set-cookie");
return headers;
}
示例3: toApmResponse
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
protected ApmResponse toApmResponse (final HttpServletResponse response) {
final ApmResponse apmResponse;
if (response != null) {
final ApmHeaders apmHeaders = new ApmHeaders ()
.withContent_type (response.getContentType ());
for (final String headerName : response.getHeaderNames ()) {
apmHeaders.withAdditionalProperty (headerName, response.getHeader (headerName));
}
apmResponse = new ApmResponse ()
.withHeaders (apmHeaders)
.withStatus_code ((double) response.getStatus ())
//TODO add missing props
;
} else {
apmResponse = null;
}
return apmResponse;
}
示例4: buildResponseLog
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
* Build log message for response out bound.
*
* @param response Response out bound.
* @return Log message.
* @since 1.0.0
*/
protected String buildResponseLog(HttpServletResponse response) {
StringBuilder sb = new StringBuilder("Server responded with a response").append(StringUtils.LF)
.append(" > ").append(response.getStatus()).append(StringUtils.LF);
Collection<String> keys = response.getHeaderNames();
for (String key : keys) {
sb.append(" > ").append(key).append(": ").append(response.getHeader(key)).append(StringUtils.LF);
}
sb.append(extractResponsePayload(response));
return sb.toString();
}
示例5: getResponHeaders
import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
* 根据HttpServletRequest获取指定格式的headers
*
* @param request
* @return
*/
private String getResponHeaders(HttpServletResponse response) {
Map<String, String> result = new HashMap<String, String>();
for (String key : response.getHeaderNames()) {
result.put(key, response.getHeader(key));
}
return JSONHelper.toString(result);
}