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


Java HttpMethod.getStatusCode方法代碼示例

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


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

示例1: SecureHttpMethodResponse

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
public SecureHttpMethodResponse(HttpMethod method, HostConfiguration hostConfig, 
        EncryptionUtils encryptionUtils) throws AuthenticationException, IOException
{
    super(method);
    this.hostConfig = hostConfig;
    this.encryptionUtils = encryptionUtils;

    if(method.getStatusCode() == HttpStatus.SC_OK)
    {
        this.decryptedBody = encryptionUtils.decryptResponseBody(method);
        // authenticate the response
        if(!authenticate())
        {
            throw new AuthenticationException(method);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:18,代碼來源:HttpClientFactory.java

示例2: isRedirect

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
private boolean isRedirect(HttpMethod method)
{
    switch (method.getStatusCode()) {
    case HttpStatus.SC_MOVED_TEMPORARILY:
    case HttpStatus.SC_MOVED_PERMANENTLY:
    case HttpStatus.SC_SEE_OTHER:
    case HttpStatus.SC_TEMPORARY_REDIRECT:
        if (method.getFollowRedirects()) {
            return true;
        } else {
            return false;
        }
    default:
        return false;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:17,代碼來源:AbstractHttpClient.java

示例3: SwiftInvalidResponseException

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
public SwiftInvalidResponseException(String message,
                                     String operation,
                                     URI uri,
                                     HttpMethod method) {
  super(message);
  this.statusCode = method.getStatusCode();
  this.operation = operation;
  this.uri = uri;
  String bodyAsString;
  try {
    bodyAsString = method.getResponseBodyAsString();
    if (bodyAsString == null) {
      bodyAsString = "";
    }
  } catch (IOException e) {
    bodyAsString = "";
  }
  this.body = bodyAsString;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:SwiftInvalidResponseException.java

示例4: executeRequest

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
/**
 * Will create the method and execute it. After this the method is sent to a
 * ResponseHandler that is returned.
 * 
 * @param httpRequest
 *            Request we are receiving from the client
 * @param url
 *            The location we are proxying to
 * @return A ResponseHandler that can be used to write the response
 * @throws MethodNotAllowedException
 *             If the method specified by the request isn't handled
 * @throws IOException
 *             When there is a problem with the streams
 * @throws HttpException
 *             The httpclient can throw HttpExcetion when executing the
 *             method
 */
ResponseHandler executeRequest(HttpServletRequest httpRequest, String url)
        throws MethodNotAllowedException, IOException, HttpException {
    RequestHandler requestHandler = RequestHandlerFactory
            .createRequestMethod(httpRequest.getMethod());

    HttpMethod method = requestHandler.process(httpRequest, url);
    method.setFollowRedirects(false);

    /*
     * Why does method.validate() return true when the method has been
     * aborted? I mean, if validate returns true the API says that means
     * that the method is ready to be executed. TODO I don't like doing type
     * casting here, see above.
     */
    if (!((HttpMethodBase) method).isAborted()) {
        httpClient.executeMethod(method);

        if (method.getStatusCode() == 405) {
            Header allow = method.getResponseHeader("allow");
            String value = allow.getValue();
            throw new MethodNotAllowedException(
                    "Status code 405 from server",
                    AllowedMethodHandler.processAllowHeader(value));
        }
    }

    return ResponseHandlerFactory.createResponseHandler(method);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:46,代碼來源:ProxyFilter.java

示例5: sendThankYouRequest

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
void sendThankYouRequest(CoalesceThankYouNotesKey key)
{
    boolean success = false;
    List requestList = this.removeRequestList(key);
    if (done || requestList == null)
    {
        return;
    }
    HttpMethod streamedPostMethod = null;
    try
    {
        if (LOGGER.isDebugEnabled())
        {
            LOGGER.debug("Sending thank you for {}", requestList.size());
        }
        AuthenticatedUrl url = key.getAuthenticatedUrl();
        HttpClient httpClient = FastServletProxyFactory.getHttpClient(url);
        httpClient.getState().addCookies(key.getCookies());
        OutputStreamWriter writer = new ThankYouStreamWriter(requestList);
        streamedPostMethod = FastServletProxyFactory.serverSupportsChunking(url) ? new StreamedPostMethod(url.getPath() + "?thanks", writer) : new BufferedPostMethod(url.getPath() + "?thanks", writer);
        httpClient.executeMethod(streamedPostMethod);

        int code = streamedPostMethod.getStatusCode();

        streamedPostMethod.getResponseBodyAsStream().close();
        streamedPostMethod.releaseConnection();
        streamedPostMethod = null;
        success = code == 200;
    }
    catch (Exception e)
    {
        LOGGER.warn("Exception in JRPIP thank you note for URL: {} Retrying.", key.toString(), e);
    }
    finally
    {
        if (streamedPostMethod != null)
        {
            streamedPostMethod.releaseConnection();
        }
    }
    if (!success)
    {
        this.readList(key, requestList);
    }
}
 
開發者ID:goldmansachs,項目名稱:jrpip,代碼行數:46,代碼來源:ThankYouWriter.java


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