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


Java RequestBuilder.build方法代码示例

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


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

示例1: adjustRequestRange

import org.asynchttpclient.RequestBuilder; //导入方法依赖的package包/类
/**
 * Invoke this API if you want to set the Range header on your {@link Request} based on the last valid bytes
 * position.
 *
 * @param request {@link Request}
 * @return a {@link Request} with the Range header properly set.
 */
public Request adjustRequestRange(Request request) {

    Long ri = resumableIndex.get(request.getUrl());
    if (ri != null) {
        byteTransferred.set(ri);
    }

    // The Resumable
    if (resumableListener != null && resumableListener.length() > 0 && byteTransferred.get() != resumableListener.length()) {
        byteTransferred.set(resumableListener.length());
    }

    RequestBuilder builder = new RequestBuilder(request);
    if (request.getHeaders().get(HttpHeaders.Names.RANGE) == null && byteTransferred.get() != 0) {
        builder.setHeader(HttpHeaders.Names.RANGE, "bytes=" + byteTransferred.get() + "-");
    }
    return builder.build();
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:26,代码来源:ResumableAsyncHandler.java

示例2: preBuildRequests

import org.asynchttpclient.RequestBuilder; //导入方法依赖的package包/类
private void preBuildRequests() {
    int pos = 0;
    requests = new Request[requestBuilders.length];
    for (RequestBuilder requestBuilder: requestBuilders) {
        requests[pos++] = requestBuilder.build();
    }
    requestBuilders = new RequestBuilder[0];
}
 
开发者ID:globocom,项目名称:groot,代码行数:9,代码来源:RequestExecutorService.java

示例3: doTestWithInputStreamBodyGenerator

import org.asynchttpclient.RequestBuilder; //导入方法依赖的package包/类
public void doTestWithInputStreamBodyGenerator(InputStream is) throws Throwable {
    try (AsyncHttpClient c = asyncHttpClient(httpClientBuilder())) {

        RequestBuilder builder = post(getTargetUrl()).setBody(new InputStreamBodyGenerator(is));

        Request r = builder.build();

        final ListenableFuture<Response> responseFuture = c.executeRequest(r);
        waitForAndAssertResponse(responseFuture);
    }
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:12,代码来源:ChunkingTest.java

示例4: doExecute

import org.asynchttpclient.RequestBuilder; //导入方法依赖的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();
	ListenableFuture<Response> future = client.executeRequest(request);

	long start = nanoTime();
	Response response = future.get();
	long duration = nanoTime() - start;
	return new AsyncHttpResponse(response, duration);
}
 
开发者ID:mjeanroy,项目名称:junit-servers,代码行数:28,代码来源:AsyncHttpRequest.java

示例5: req

import org.asynchttpclient.RequestBuilder; //导入方法依赖的package包/类
private Request req(String method, String url) {
    RequestBuilder builder = new RequestBuilder(method);
    if (realm != null) {
        builder.setRealm(realm);
    } else {
        builder.addHeader("Authorization", "Bearer " + oauthToken);
    }
    builder.setUrl(RESTRICTED_PATTERN.matcher(url).replaceAll("+")); // replace out %2B with + due to API restriction
    return builder.build();
}
 
开发者ID:cloudbees,项目名称:zendesk-java-client,代码行数:11,代码来源:Zendesk.java


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