本文整理汇总了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();
}
示例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];
}
示例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);
}
}
示例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);
}
示例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();
}