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


Java HttpStatus.SC_TEMPORARY_REDIRECT屬性代碼示例

本文整理匯總了Java中org.apache.http.HttpStatus.SC_TEMPORARY_REDIRECT屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpStatus.SC_TEMPORARY_REDIRECT屬性的具體用法?Java HttpStatus.SC_TEMPORARY_REDIRECT怎麽用?Java HttpStatus.SC_TEMPORARY_REDIRECT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.http.HttpStatus的用法示例。


在下文中一共展示了HttpStatus.SC_TEMPORARY_REDIRECT屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isRedirected

public boolean isRedirected(
        final HttpRequest request,
        final HttpResponse response,
        final HttpContext context) throws ProtocolException {
    if (request == null) {
        throw new IllegalArgumentException("HTTP request may not be null");
    }
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }

    int statusCode = response.getStatusLine().getStatusCode();
    String method = request.getRequestLine().getMethod();
    Header locationHeader = response.getFirstHeader("location");
    switch (statusCode) {
    case HttpStatus.SC_MOVED_TEMPORARILY:
        return isRedirectable(method) && locationHeader != null;
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        return isRedirectable(method);
    case HttpStatus.SC_SEE_OTHER:
        return true;
    default:
        return false;
    } //end of switch
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:DefaultRedirectStrategy.java

示例2: isRedirectRequested

public boolean isRedirectRequested(
        final HttpResponse response,
        final HttpContext context) {
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }

    int statusCode = response.getStatusLine().getStatusCode();
    switch (statusCode) {
    case HttpStatus.SC_MOVED_TEMPORARILY:
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        HttpRequest request = (HttpRequest) context.getAttribute(
                ExecutionContext.HTTP_REQUEST);
        String method = request.getRequestLine().getMethod();
        return method.equalsIgnoreCase(HttpGet.METHOD_NAME)
            || method.equalsIgnoreCase(HttpHead.METHOD_NAME);
    case HttpStatus.SC_SEE_OTHER:
        return true;
    default:
        return false;
    } //end of switch
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:DefaultRedirectHandler.java

示例3: isRedirectRequested

@Override
public boolean isRedirectRequested(
        final HttpResponse response,
        final HttpContext context) {
    if (!enableRedirects) {
        return false;
    }
    if (response == null) {
        throw new IllegalArgumentException("HTTP response may not be null");
    }
    int statusCode = response.getStatusLine().getStatusCode();
    switch (statusCode) {
        case HttpStatus.SC_MOVED_TEMPORARILY:
        case HttpStatus.SC_MOVED_PERMANENTLY:
        case HttpStatus.SC_SEE_OTHER:
        case HttpStatus.SC_TEMPORARY_REDIRECT:
            return true;
        default:
            return false;
    } //end of switch
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:21,代碼來源:MyRedirectHandler.java

示例4: record

private Response record(Interceptor.Chain chain) throws IOException {
    Request request = chain.request();
    NetworkCallRecord networkCallRecord = new NetworkCallRecord();

    networkCallRecord.Headers = new HashMap<>();

    if (request.header("Content-Type") != null) {
        networkCallRecord.Headers.put("Content-Type", request.header("Content-Type"));
    }
    if (request.header("x-ms-version") != null) {
        networkCallRecord.Headers.put("x-ms-version", request.header("x-ms-version"));
    }
    if (request.header("User-Agent") != null) {
        networkCallRecord.Headers.put("User-Agent", request.header("User-Agent"));
    }

    networkCallRecord.Method = request.method();
    networkCallRecord.Uri = applyReplacementRule(request.url().toString().replaceAll("\\?$", ""));

    Response response = chain.proceed(request);

    networkCallRecord.Response = new HashMap<>();
    networkCallRecord.Response.put("StatusCode", Integer.toString(response.code()));
    extractResponseData(networkCallRecord.Response, response);

    // remove pre-added header if this is a waiting or redirection
    if (networkCallRecord.Response.get("Body").contains("<Status>InProgress</Status>")
            || Integer.parseInt(networkCallRecord.Response.get("StatusCode")) == HttpStatus.SC_TEMPORARY_REDIRECT) {
        // Do nothing
    } else {
        synchronized (recordedData.getNetworkCallRecords()) {
            recordedData.getNetworkCallRecords().add(networkCallRecord);
        }
    }

    return response;
}
 
開發者ID:Azure,項目名稱:azure-libraries-for-java,代碼行數:37,代碼來源:InterceptorManager.java

示例5: isTemporaryRedirect

private static boolean isTemporaryRedirect(org.apache.http.HttpResponse response) {
    int status = response.getStatusLine().getStatusCode();
    return status == HttpStatus.SC_TEMPORARY_REDIRECT && response.getHeaders("Location") != null
           && response.getHeaders("Location").length > 0;
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:5,代碼來源:AmazonHttpClient.java


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