/** * Set connect timeout on connection to given value * * @param timeout * @return this request */ public HttpRequest connectTimeout(final int timeout) { getConnection().setConnectTimeout(timeout); return this; }
/** * Set connect timeout on connection to given value * * @param timeout * @return this request */ public HttpRequest connectTimeout(final int timeout) { getConnection().setConnectTimeout(timeout); return this; }
/** * Set the 'Content-Length' request header to the given value * * @param contentLength * @return this request */ public HttpRequest contentLength(final int contentLength) { getConnection().setFixedLengthStreamingMode(contentLength); return this; }
/** * Get the {@link URL} of this request's connection * * @return request URL */ public URL url() { return getConnection().getURL(); }
/** * Set read timeout on connection to given value * * @param timeout * @return this request */ public HttpRequest readTimeout(final int timeout) { getConnection().setReadTimeout(timeout); return this; }
/** * Set header name to given value * * @param name * @param value * @return this request */ public HttpRequest header(final String name, final String value) { getConnection().setRequestProperty(name, value); return this; }
/** * Set whether or not the underlying connection should follow redirects in * the response. * * @param followRedirects - true fo follow redirects, false to not. * @return this request */ public HttpRequest followRedirects(final boolean followRedirects) { getConnection().setInstanceFollowRedirects(followRedirects); return this; } }
/** * Get the {@link URL} of this request's connection * * @return request URL */ public URL url() { return getConnection().getURL(); }
/** * Set whether or not the underlying connection should follow redirects in * the response. * * @param followRedirects - true fo follow redirects, false to not. * @return this request */ public HttpRequest followRedirects(final boolean followRedirects) { getConnection().setInstanceFollowRedirects(followRedirects); return this; } }
/** * Disconnect the connection * * @return this request */ public HttpRequest disconnect() { getConnection().disconnect(); return this; }
/** * Set value of {@link HttpURLConnection#setUseCaches(boolean)} * * @param useCaches * @return this request */ public HttpRequest useCaches(final boolean useCaches) { getConnection().setUseCaches(useCaches); return this; }
/** * Set the 'Content-Length' request header to the given value * * @param contentLength * @return this request */ public HttpRequest contentLength(final int contentLength) { getConnection().setFixedLengthStreamingMode(contentLength); return this; }
/** * Set header name to given value * * @param name * @param value * @return this request */ public HttpRequest header(final String name, final String value) { getConnection().setRequestProperty(name, value); return this; }
/** * Get a response header * * @param name * @return response header * @throws HttpRequestException */ public String header(final String name) throws HttpRequestException { closeOutputQuietly(); return getConnection().getHeaderField(name); }
/** * Set the 'If-Modified-Since' request header to the given value * * @param ifModifiedSince * @return this request */ public HttpRequest ifModifiedSince(final long ifModifiedSince) { getConnection().setIfModifiedSince(ifModifiedSince); return this; }
/** * Get all the response headers * * @return map of response header names to their value(s) * @throws HttpRequestException */ public Map<String, List<String>> headers() throws HttpRequestException { closeOutputQuietly(); return getConnection().getHeaderFields(); }
/** * Set chunked streaming mode to the given size * * @param size * @return this request */ public HttpRequest chunk(final int size) { getConnection().setChunkedStreamingMode(size); return this; }
/** * Get the HTTP method of this request * * @return method */ public String method() { return getConnection().getRequestMethod(); }
/** * Set the 'If-Modified-Since' request header to the given value * * @param ifModifiedSince * @return this request */ public HttpRequest ifModifiedSince(final long ifModifiedSince) { getConnection().setIfModifiedSince(ifModifiedSince); return this; }
public ResponseImpl( HttpRequest request ) { body = request.body(); contentType = request.contentType(); headers = request.headers(); code = request.code(); url = request.getConnection().getURL().toString(); request.disconnect(); }