當前位置: 首頁>>代碼示例>>Java>>正文


Java Response.getHeader方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:buttercoin,項目名稱:buttercoin-java,代碼行數:13,代碼來源:Status202ExtractLocation.java

示例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);
    }
}
 
開發者ID:yahoo,項目名稱:parsec-libraries,代碼行數:73,代碼來源:ParsecClientProfilingLogUtil.java

示例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);

}
 
開發者ID:tootedom,項目名稱:tomcat-memcached-response-filter,代碼行數:5,代碼來源:TestFilterConfiguration.java

示例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


注:本文中的com.ning.http.client.Response.getHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。