Java Code Examples for com.ning.http.client.RequestBuilder#build()

The following examples show how to use com.ning.http.client.RequestBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NingAsyncHttpRequest.java    From junit-servers with MIT License 6 votes vote down vote up
@Override
protected HttpResponse doExecute() throws Exception {
	final HttpUrl endpoint = getEndpoint();
	final String scheme = endpoint.getScheme();
	final String userInfo = null;
	final String host = endpoint.getHost();
	final int port = endpoint.getPort();
	final String path = UTF8UrlEncoder.encodePath(endpoint.getPath());
	final String query = null;
	final Uri uri = new Uri(scheme, userInfo, host, port, path, query);

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

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

	final Request request = builder.build();
	final long start = nanoTime();
	final Response response = client.executeRequest(request).get();
	final long duration = nanoTime() - start;

	return NingAsyncHttpResponseFactory.of(response, duration);
}
 
Example 2
Source File: Zendesk.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private Request req(String method, Uri template) {
    RequestBuilder builder = new RequestBuilder(method);
    if (realm != null) {
        builder.setRealm(realm);
    } else {
        builder.addHeader("Authorization", "Bearer " + oauthToken);
    }
    builder.setUrl(template.toString());
    return builder.build();
}
 
Example 3
Source File: Zendesk.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private Request req(String method, Uri template, String contentType, byte[] body) {
    RequestBuilder builder = new RequestBuilder(method);
    if (realm != null) {
        builder.setRealm(realm);
    } else {
        builder.addHeader("Authorization", "Bearer " + oauthToken);
    }
    builder.setUrl(template.toString());
    builder.addHeader("Content-type", contentType);
    builder.setBody(body);
    return builder.build();
}
 
Example 4
Source File: Zendesk.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private Request req(String method, Uri template, int page) {
    RequestBuilder builder = new RequestBuilder(method);
    if (realm != null) {
        builder.setRealm(realm);
    } else {
        builder.addHeader("Authorization", "Bearer " + oauthToken);
    }
    builder.addQueryParameter("page", Integer.toString(page));
    builder.setUrl(template.toString().replace("%2B", "+")); //replace out %2B with + due to API restriction
    return builder.build();
}