/** * Set the 'Authorization' header to given values in Basic authentication * format * * @param name * @param password * @return this request */ public HttpRequest basic(final String name, final String password) { return authorization("Basic " + Base64.encode(name + ':' + password)); }
/** * Set the 'Proxy-Authorization' header to given values in Basic authentication * format * * @param name * @param password * @return this request */ public HttpRequest proxyBasic(final String name, final String password) { return proxyAuthorization("Basic " + Base64.encode(name + ':' + password)); }
/** * Call {@link #closeOutput()} and re-throw a caught {@link IOException}s as * an {@link HttpRequestException} * * @return this request * @throws HttpRequestException */ protected HttpRequest closeOutputQuietly() throws HttpRequestException { try { return closeOutput(); } catch (IOException e) { throw new HttpRequestException(e); } }
/** * Set the 'Accept-Encoding' header to given value * * @param acceptEncoding * @return this request */ public HttpRequest acceptEncoding(final String acceptEncoding) { return header(HEADER_ACCEPT_ENCODING, acceptEncoding); }
private HttpURLConnection createConnection() { try { final HttpURLConnection connection; if (httpProxyHost != null) connection = CONNECTION_FACTORY.create(url, createProxy()); else connection = CONNECTION_FACTORY.create(url); connection.setRequestMethod(requestMethod); return connection; } catch (IOException e) { throw new HttpRequestException(e); } }
/** * Start a 'DELETE' request to the given URL * * @param url * @return request * @throws HttpRequestException */ public static HttpRequest delete(final CharSequence url) throws HttpRequestException { return new HttpRequest(url, METHOD_DELETE); }
/** * Get underlying connection * * @return connection */ public HttpURLConnection getConnection() { if (connection == null) connection = createConnection(); return connection; }
/** * Set the 'Authorization' header to given values in Basic authentication * format * * @param name * @param password * @return this request */ public HttpRequest basic(final String name, final String password) { return authorization("Basic " + Base64.encode(name + ':' + password)); }
/** * Set the 'Accept-Charset' header to given value * * @param acceptCharset * @return this request */ public HttpRequest acceptCharset(final String acceptCharset) { return header(HEADER_ACCEPT_CHARSET, acceptCharset); }
/** * Call {@link #closeOutput()} and re-throw a caught {@link IOException}s as * an {@link HttpRequestException} * * @return this request * @throws HttpRequestException */ protected HttpRequest closeOutputQuietly() throws HttpRequestException { try { return closeOutput(); } catch (IOException e) { throw new HttpRequestException(e); } }
/** * Start a 'HEAD' request to the given URL * * @param url * @return request * @throws HttpRequestException */ public static HttpRequest head(final CharSequence url) throws HttpRequestException { return new HttpRequest(url, METHOD_HEAD); }
/** * Set the 'Proxy-Authorization' header to given values in Basic authentication * format * * @param name * @param password * @return this request */ public HttpRequest proxyBasic(final String name, final String password) { return proxyAuthorization("Basic " + Base64.encode(name + ':' + password)); }
/** * Set the 'Authorization' header to given values in Basic authentication * format * * @param name * @param password * @return this request */ public HttpRequest basic(final String name, final String password) { return authorization("Basic " + Base64.encode(name + ':' + password)); }
/** * Get the 'Server' header from the response * * @return server */ public String server() { return header(HEADER_SERVER); }
/** * Start a 'DELETE' request to the given URL * * @param url * @return request * @throws HttpRequestException */ public static HttpRequest delete(final URL url) throws HttpRequestException { return new HttpRequest(url, METHOD_DELETE); }
/** * Set the 'Authorization' header to given values in Basic authentication * format * * @param name * @param password * @return this request */ public HttpRequest basic(final String name, final String password) { return authorization("Basic " + Base64.encode(name + ':' + password)); }
/** * Set the 'Authorization' header to given value * * @param authorization * @return this request */ public HttpRequest authorization(final String authorization) { return header(HEADER_AUTHORIZATION, authorization); }
/** * Start a 'HEAD' request to the given URL * * @param url * @return request * @throws HttpRequestException */ public static HttpRequest head(final URL url) throws HttpRequestException { return new HttpRequest(url, METHOD_HEAD); }
/** * Set the 'Proxy-Authorization' header to given value * * @param proxyAuthorization * @return this request */ public HttpRequest proxyAuthorization(final String proxyAuthorization) { return header(HEADER_PROXY_AUTHORIZATION, proxyAuthorization); }