Java Code Examples for org.asynchttpclient.RequestBuilder#addHeader()

The following examples show how to use org.asynchttpclient.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 zendesk-java-client with Apache License 2.0 5 votes vote down vote up
private RequestBuilder reqBuilder(String method, String url) {
    RequestBuilder builder = new RequestBuilder(method);
    if (realm != null) {
        builder.setRealm(realm);
    } else {
        builder.addHeader("Authorization", "Bearer " + oauthToken);
    }
    headers.forEach(builder::setHeader);
    return builder.setUrl(RESTRICTED_PATTERN.matcher(url).replaceAll("+")); // replace out %2B with + due to API restriction
}
 
Example 2
Source File: CocWebApiClient.java    From async-gamequery-lib with MIT License 4 votes vote down vote up
@Override
protected void applyAuthenticationScheme(RequestBuilder requestBuilder, String authToken) {
    requestBuilder.addHeader("authorization", String.format("Bearer %s", authToken));
}
 
Example 3
Source File: Zendesk.java    From zendesk-java-client with Apache License 2.0 4 votes vote down vote up
private Request req(String method, Uri template, String contentType, byte[] body) {
    RequestBuilder builder = reqBuilder(method, template.toString());
    builder.addHeader("Content-type", contentType);
    builder.setBody(body);
    return builder.build();
}
 
Example 4
Source File: AsyncHttpRequest.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(Cookie)
 */
private void handleCookies(RequestBuilder builder) {
	if (!cookies.isEmpty()) {
		builder.addHeader(HttpHeaders.COOKIE, Cookies.serialize(cookies));
	}
}