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


Java Uri類代碼示例

本文整理匯總了Java中com.ning.http.client.uri.Uri的典型用法代碼示例。如果您正苦於以下問題:Java Uri類的具體用法?Java Uri怎麽用?Java Uri使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: getCircuitBreaker

import com.ning.http.client.uri.Uri; //導入依賴的package包/類
protected Optional<CircuitBreaker<Response>> getCircuitBreaker(RequestBuilderWrapper requestBuilderWrapper) {
    if (requestBuilderWrapper.disableCircuitBreaker)
        return Optional.empty();

    // Circuit breaking is enabled for this call. So we return the custom one specified or use the default one if a
    //      custom one is not specified.
    if (requestBuilderWrapper.customCircuitBreaker.isPresent())
        return requestBuilderWrapper.customCircuitBreaker;

    // No custom circuit breaker. Use the default for the given request's host.
    Uri uri = Uri.create(requestBuilderWrapper.url);
    String host = uri.getHost();
    EventLoop nettyEventLoop = requestBuilderWrapper.getCtx() == null
                               ? null
                               : requestBuilderWrapper.getCtx().channel().eventLoop();
    CircuitBreaker<Integer> defaultStatusCodeCircuitBreaker = getDefaultHttpStatusCodeCircuitBreakerForKey(
        host, Optional.ofNullable(nettyEventLoop), Optional.ofNullable(nettyEventLoop)
    );
    return Optional.of(
        new CircuitBreakerDelegate<>(
            defaultStatusCodeCircuitBreaker, response -> (response == null ? null : response.getStatusCode())
        )
    );
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:25,代碼來源:AsyncHttpClientHelper.java

示例2: doExecute

import com.ning.http.client.uri.Uri; //導入依賴的package包/類
@Override
protected HttpResponse doExecute() throws Exception {
	HttpUrl endpoint = getEndpoint();
	String scheme = endpoint.getScheme();
	String userInfo = null;
	String host = endpoint.getHost();
	int port = endpoint.getPort();
	String path = UTF8UrlEncoder.encodePath(endpoint.getPath());
	String query = null;
	Uri uri = new Uri(scheme, userInfo, host, port, path, query);

	String method = getMethod().getVerb();
	RequestBuilder builder = new RequestBuilder(method, true).setUri(uri);

	handleQueryParameters(builder);
	handleBody(builder);
	handleHeaders(builder);
	handleCookies(builder);

	Request request = builder.build();
	long start = nanoTime();
	Response response = client.executeRequest(request).get();
	return new NingAsyncHttpResponse(response, nanoTime() - start);
}
 
開發者ID:mjeanroy,項目名稱:junit-servers,代碼行數:25,代碼來源:NingAsyncHttpRequest.java

示例3: testLogRemoteRequest

import com.ning.http.client.uri.Uri; //導入依賴的package包/類
@Test
public void testLogRemoteRequest() {
    Request req = mock(Request.class);
    when(req.getUri()).thenReturn(Uri.create("http://test.yahoo.com"));
    when(req.getHeaders()).thenReturn(new FluentCaseInsensitiveStringsMap());
    Response resp = mock(Response.class);
    when(resp.getHeader(anyString())).thenReturn("mock resp header");
    when(resp.getHeader("content-length")).thenReturn("100");

    String reqStatus = "test_status";
    ParsecAsyncProgress progress = new ParsecAsyncProgress();

    ParsecClientProfilingLogUtil.logRemoteRequest(req, resp, reqStatus, progress);
    ParsecClientProfilingLogUtil.logRemoteRequest(req, null, reqStatus, progress);
}
 
開發者ID:yahoo,項目名稱:parsec-libraries,代碼行數:16,代碼來源:ParsecClientProfilingLogUtilTest.java

示例4: verifyRequestBuilderWrapperGeneratedAsExpected

import com.ning.http.client.uri.Uri; //導入依賴的package包/類
private void verifyRequestBuilderWrapperGeneratedAsExpected(
    RequestBuilderWrapper rbw, String url, String method, Optional<CircuitBreaker<Response>> customCb,
    boolean disableCb
) {
    assertThat(rbw.url).isEqualTo(url);
    assertThat(rbw.httpMethod).isEqualTo(method);
    assertThat(rbw.customCircuitBreaker).isEqualTo(customCb);
    assertThat(rbw.disableCircuitBreaker).isEqualTo(disableCb);
    Request req = rbw.requestBuilder.build();
    assertThat(req.getMethod()).isEqualTo(method);
    assertThat(req.getUri()).isEqualTo(Uri.create(url));
    assertThat(req.getUrl()).isEqualTo(url);
    assertThat(req.getNameResolver()).isEqualTo(MultiIpAwareNameResolver.INSTANCE);
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:15,代碼來源:AsyncHttpClientHelperTest.java

示例5: build

import com.ning.http.client.uri.Uri; //導入依賴的package包/類
/**
 * Buile new {@link ParsecAsyncHttpRequest} instance.
 *
 * @return {@link ParsecAsyncHttpRequest}
 */
@SuppressWarnings("PMD.NPathComplexity")
public ParsecAsyncHttpRequest build() {
    ningRequestBuilder = new RequestBuilder(method)
        .setContentLength(contentLength)
        .setFollowRedirects(followRedirect)
        .setHeaders(headers)
        .setProxyServer(proxyServer)
        .setRangeOffset(rangeOffset)
        .setRequestTimeout(requestTimeout)
        .setVirtualHost(virtualHost)
        .setUri(new Uri(
            uri.getScheme(),
            uri.getUserInfo(),
            uri.getHost(),
            uri.getPort(),
            uri.getPath(),
            uri.getRawQuery()
    ));

    if (body != null) {
        ningRequestBuilder.setBody(body);
    } else if (byteBody != null) {
        ningRequestBuilder.setBody(byteBody);
    }

    if (bodyEncoding != null) {
        ningRequestBuilder.setBodyEncoding(bodyEncoding);
    }

    if (cookies != null && !cookies.isEmpty()) {
        for (NewCookie cookie : cookies) {
            ningRequestBuilder.addCookie(new Cookie(
                cookie.getName(),
                cookie.getValue(),
                false,
                cookie.getDomain(),
                cookie.getPath(),
                cookie.getMaxAge(),
                cookie.isSecure(),
                cookie.isHttpOnly()
            ));
        }
    }

    if (formParams != null) {
        ningRequestBuilder.setFormParams(formParams);
    }

    if (queryParams != null) {
        ningRequestBuilder.setQueryParams(queryParams);
    }

    if (acceptCompression && !headers.containsKey(ACCEPT_ENCODING_HEADER)) {
        ningRequestBuilder.addHeader(ACCEPT_ENCODING_HEADER, COMPRESSION_TYPE);
    }

    for (Part part: bodyParts) {
        ningRequestBuilder.addBodyPart(part);
    }

    return new ParsecAsyncHttpRequest(this);
}
 
開發者ID:yahoo,項目名稱:parsec-libraries,代碼行數:68,代碼來源:ParsecAsyncHttpRequest.java


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