当前位置: 首页>>代码示例>>Java>>正文


Java HttpMethod.setURI方法代码示例

本文整理汇总了Java中org.apache.commons.httpclient.HttpMethod.setURI方法的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod.setURI方法的具体用法?Java HttpMethod.setURI怎么用?Java HttpMethod.setURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.httpclient.HttpMethod的用法示例。


在下文中一共展示了HttpMethod.setURI方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeURI

import org.apache.commons.httpclient.HttpMethod; //导入方法依赖的package包/类
/**
 * Execute a transaction method given a complete URI.
 * @param method the transaction method
 * @param headers HTTP header values to send
 * @param uri a properly urlencoded URI
 * @return the HTTP response code
 * @throws IOException
 */
public int executeURI(HttpMethod method, Header[] headers, String uri)
    throws IOException {
  method.setURI(new URI(uri, true));
  for (Map.Entry<String, String> e: extraHeaders.entrySet()) {
    method.addRequestHeader(e.getKey(), e.getValue());
  }
  if (headers != null) {
    for (Header header: headers) {
      method.addRequestHeader(header);
    }
  }
  long startTime = System.currentTimeMillis();
  int code = httpClient.executeMethod(method);
  long endTime = System.currentTimeMillis();
  if (LOG.isDebugEnabled()) {
    LOG.debug(method.getName() + " " + uri + " " + code + " " +
      method.getStatusText() + " in " + (endTime - startTime) + " ms");
  }
  return code;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:Client.java

示例2: sendRemoteRequest

import org.apache.commons.httpclient.HttpMethod; //导入方法依赖的package包/类
/**
 * Send Request to the repository
 */
protected HttpMethod sendRemoteRequest(Request req) throws AuthenticationException, IOException
{
    if (logger.isDebugEnabled())
    {
        logger.debug("");
        logger.debug("* Request: " + req.getMethod() + " " + req.getFullUri() + (req.getBody() == null ? "" : "\n" + new String(req.getBody(), "UTF-8")));
    }

    HttpMethod method = createMethod(req);

    // execute method
    executeMethod(method);

    // Deal with redirect
    if(isRedirect(method))
    {
        Header locationHeader = method.getResponseHeader("location");
        if (locationHeader != null)
        {
            String redirectLocation = locationHeader.getValue();
            method.setURI(new URI(redirectLocation, true));
            httpClient.executeMethod(method);
        }
    }

    return method;
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:31,代码来源:AbstractHttpClient.java


注:本文中的org.apache.commons.httpclient.HttpMethod.setURI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。