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