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


Java HttpRequestBase.getURI方法代碼示例

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


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

示例1: executeHttpRequest

import org.apache.http.client.methods.HttpRequestBase; //導入方法依賴的package包/類
protected HttpResponse executeHttpRequest(HttpRequestBase httpRequest, String method) {

		CloseableHttpResponse response = null;
		try {
			response = httpClient.execute(httpRequest);
		} catch (IOException e) {
			throw new ActivitiException("error while executing http request: " + method + " " + httpRequest.getURI(),
					e);
		}

		if (response.getStatusLine().getStatusCode() >= 400) {
			throw new ActivitiException("error while executing http request " + method + " " + httpRequest.getURI()
					+ " with status code: " + response.getStatusLine().getStatusCode());
		}
		return response;
	}
 
開發者ID:cijujoseph,項目名稱:activiti-analytics-spring-boot,代碼行數:17,代碼來源:ElasticHTTPClient.java

示例2: getWebContentPrivate

import org.apache.http.client.methods.HttpRequestBase; //導入方法依賴的package包/類
private ResponseImpl getWebContentPrivate(Request request, @Nullable ProxyDetails proxy, boolean followRedirects)
{
	final String url = request.getUrl();
	try
	{
		@SuppressWarnings("unused")
		URL u = new URL(url); // NOSONAR
	}
	catch( MalformedURLException ex )
	{
		return new ResponseImpl(HttpServletResponse.SC_BAD_REQUEST, "Invalid URL: " + url);
	}
	HttpRequestBase httpMethod = null;
	try
	{
		httpMethod = getHttpMethod(request);
		if( httpMethod == null )
		{
			return new ResponseImpl(HttpServletResponse.SC_METHOD_NOT_ALLOWED,
				"Only GET, POST, HEAD, PUT, DELETE and OPTIONS methods are supported");
		}
		if( !followRedirects )
		{
			HttpClientParams.setRedirecting(httpMethod.getParams(), false);
		}

		final DefaultHttpClient client = createClient(httpMethod.getURI().getScheme().equals("https"));

		if( proxy != null && proxy.isConfigured() )
		{
			final URI uri = httpMethod.getURI();
			final String host = uri.getHost();
			if( !proxy.isHostExcepted(host) )
			{
				final HttpHost proxyHost = new HttpHost(proxy.getHost(), proxy.getPort());
				client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxyHost);
				if( !Check.isEmpty(proxy.getUsername()) )
				{
					client.getCredentialsProvider().setCredentials(
						new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
						new UsernamePasswordCredentials(proxy.getUsername(), proxy.getPassword()));

				}
			}
		}

		// TODO: see fixme about cookie cache
		final String cacheKey = /* req.getSession().getId() */"FIXME" + ':' + url;
		Cookies cookies = COOKIE_CACHE.getIfPresent(cacheKey);
		if( cookies == null )
		{
			cookies = new Cookies();
			COOKIE_CACHE.put(cacheKey, cookies);
		}

		final HttpResponse response = exec(client, httpMethod, cookies);
		return new ResponseImpl(response, httpMethod);
	}
	catch( Exception e )
	{
		throw new RuntimeException(e);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:64,代碼來源:HttpServiceImpl.java

示例3: adicionarFiltros

import org.apache.http.client.methods.HttpRequestBase; //導入方法依賴的package包/類
private void adicionarFiltros(HttpRequestBase httpRequestClient, Date inicio, Date fim, StatusPagamentoBoleto pago)
          throws URISyntaxException {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
      URIBuilder uriBuilder = new URIBuilder(httpRequestClient.getURI());

      uriBuilder.addParameter("data_inicio", formatter.format(inicio));
      uriBuilder.addParameter("data_fim", formatter.format(fim));
      uriBuilder.addParameter("pago", pago.getName());

      httpRequestClient.setURI(uriBuilder.build());
  }
 
開發者ID:pjbank,項目名稱:pjbank-java-sdk,代碼行數:12,代碼來源:BoletosManager.java

示例4: adicionarFiltros

import org.apache.http.client.methods.HttpRequestBase; //導入方法依賴的package包/類
private void adicionarFiltros(HttpRequestBase httpRequestClient, Map<String, String> filters)
        throws URISyntaxException {
    if (filters != null && !filters.isEmpty()) {
        URIBuilder uriBuilder = new URIBuilder(httpRequestClient.getURI());

        for (String key : filters.keySet()) {
            uriBuilder.addParameter(key, filters.get(key));
        }

        httpRequestClient.setURI(uriBuilder.build());
    }
}
 
開發者ID:pjbank,項目名稱:pjbank-java-sdk,代碼行數:13,代碼來源:CartaoCreditoManager.java

示例5: uri_resourcepath_escapes_double_slash

import org.apache.http.client.methods.HttpRequestBase; //導入方法依賴的package包/類
@Test
public void uri_resourcepath_escapes_double_slash() throws IOException, URISyntaxException {

    final Request<Object> request = newDefaultRequest(HttpMethodName.GET);
    request.setResourcePath("//foo");
    request.setEndpoint(new URI(ENDPOINT));
    HttpRequestBase requestBase = requestFactory.create(request, settings);
    URI expectredUri = requestBase.getURI();
    Assert.assertEquals("/%2Ffoo", expectredUri.getRawPath());
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:11,代碼來源:ApacheDefaultHttpRequestFactoryTest.java


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