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

The following examples show how to use com.ning.http.client.RequestBuilder#addHeader() . 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: 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 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, 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 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, 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();
}
 
Example 4
Source File: NingAsyncHttpRequest.java    From junit-servers with MIT License 2 votes vote down vote up
/**
 * Add cookies to the final HTTP request.
 *
 * @param builder The pending HTTP request.
 * @see RequestBuilder#addCookie(com.ning.http.client.cookie.Cookie)
 */
private void handleCookies(RequestBuilder builder) {
	if (!cookies.isEmpty()) {
		builder.addHeader(HttpHeaders.COOKIE, Cookies.serialize(cookies));
	}
}