当前位置: 首页>>代码示例>>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;未经允许,请勿转载。