本文整理匯總了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);
}