本文整理汇总了Java中com.ning.http.client.Response.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getHeader方法的具体用法?Java Response.getHeader怎么用?Java Response.getHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ning.http.client.Response
的用法示例。
在下文中一共展示了Response.getHeader方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCacheHeader
import com.ning.http.client.Response; //导入方法依赖的package包/类
private String getCacheHeader(String url,boolean nocache) throws Exception {
AsyncHttpClient.BoundRequestBuilder builder = server.getHttpClient().prepareGet(url);
if(nocache) {
builder.addHeader("Cache-Control","no-cache");
}
Request r = builder.build();
Response cachedResponse = server.getHttpClient().executeRequest(r).get();
return cachedResponse.getHeader(CacheConfigGlobals.DEFAULT_CACHE_STATUS_HEADER_NAME);
}
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:12,代码来源:TestResponseIsCachedForMaxAge.java
示例2: apply
import com.ning.http.client.Response; //导入方法依赖的package包/类
@Override
public URL apply(Response response) {
if (response.getStatusCode() != 202)
throw new RuntimeException("Not a 202 Created response: " + response.getStatusCode() + " " + response.getStatusText());
try {
return new URL(response.getHeader("Location"));
}
catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
示例3: getCacheHeader
import com.ning.http.client.Response; //导入方法依赖的package包/类
private String getCacheHeader(String url) throws Exception {
Request r = server.getHttpClient().prepareGet(url).build();
Response cachedResponse = server.getHttpClient().executeRequest(r).get();
String header = cachedResponse.getHeader(CacheConfigGlobals.DEFAULT_CACHE_STATUS_HEADER_NAME);
return header;
}
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:8,代码来源:TestResponseIsNotCachedDueToStatusCodes.java
示例4: logRemoteRequest
import com.ning.http.client.Response; //导入方法依赖的package包/类
/**
* log remote profiling log.
*
* @param request ning http request
* @param response ning http response
* @param requestStatus request status
* @param progress parsec async progress do
* @param msgMap additional log msg in key=String, value=String format
*/
public static void logRemoteRequest(
final Request request,
final Response response,
final String requestStatus,
final ParsecAsyncProgress progress,
final Map<String, String> msgMap
) {
if (!PROF_LOGGER.isTraceEnabled()) {
return;
}
//
// prepare log data
//
long now = System.currentTimeMillis();
BigDecimal timeInSecond = new BigDecimal(now).divide(BigDecimal.valueOf(DateUtils.MILLIS_PER_SECOND));
String contentLength = "";
String origin = "";
int respCode = -1;
String reqUrl = request.getUri().toUrl();
String reqMethod = request.getMethod();
String reqHostHeader = request.getHeaders().getFirstValue(ParsecClientDefine.HEADER_HOST);
if (response != null) {
contentLength = response.getHeader(ParsecClientDefine.HEADER_CONTENT_LENGTH);
respCode = response.getStatusCode();
}
try {
String executeInfo = OBJECT_MAPPER.writeValueAsString(progress);
//
// FIXME: should implement a servlet filter to set $_SERVER['REQUEST_URI']
//
String srcUrl = "";
StringBuilder stringBuilder = new StringBuilder()
.append("time=").append(timeInSecond).append(", ")
.append("req_url=").append(reqUrl).append(", ")
.append("req_host_header=").append(reqHostHeader).append(", ")
.append("req_method=").append(reqMethod).append(", ")
.append("exec_info=").append(executeInfo).append(", ")
.append("resp_code=").append(respCode).append(", ")
.append("src_url=").append(srcUrl).append(", ")
.append("req_status=").append(requestStatus).append(", ")
.append("content_length=").append(contentLength).append(", ")
.append("origin=").append(origin).append(", ");
if(msgMap != null){
for (Map.Entry<String, String> entry : msgMap.entrySet()){
stringBuilder.append(entry.getKey()).append("=").append(entry.getValue()).append(", ");
}
}
String logMsg = stringBuilder.toString();
//logging
PROF_LOGGER.trace(logMsg);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
示例5: getHeaderTime
import com.ning.http.client.Response; //导入方法依赖的package包/类
private String getHeaderTime(Response response) {
return response.getHeader("X-LastTime");
}
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:4,代码来源:TestResponseIsNotCachedForContentLargerThanBuffer.java
示例6: getCacheHeader
import com.ning.http.client.Response; //导入方法依赖的package包/类
private String getCacheHeader(String url,String headerName) throws Exception {
AsyncHttpClient.BoundRequestBuilder builder = server.getHttpClient().prepareGet(url);
Request r = builder.build();
Response cachedResponse = server.getHttpClient().executeRequest(r).get();
return cachedResponse.getHeader(headerName);
}
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:10,代码来源:TestCacheHitAndMissHeaderCanBeChanged.java
示例7: getCacheHeader
import com.ning.http.client.Response; //导入方法依赖的package包/类
private String getCacheHeader(Response response) {
return response.getHeader(CacheConfigGlobals.DEFAULT_CACHE_STATUS_HEADER_NAME);
}
示例8: getCacheHeader
import com.ning.http.client.Response; //导入方法依赖的package包/类
private String getCacheHeader(Response cachedResponse) throws Exception {
return cachedResponse.getHeader(CacheConfigGlobals.DEFAULT_CACHE_STATUS_HEADER_NAME);
}
开发者ID:tootedom,项目名称:tomcat-memcached-response-filter,代码行数:5,代码来源:TestResponseIsCachedForOutputStream.java