Class LowLevelHttpRequest
java.lang.Object
com.google.api.client.http.LowLevelHttpRequest
- Direct Known Subclasses:
Apache5HttpRequest, ApacheHttpRequest, ApacheHttpRequest, HttpHeaders.HeaderParsingFakeLevelHttpRequest, MockLowLevelHttpRequest, NetHttpRequest
Low-level HTTP request.
This allows providing a different implementation of the HTTP request that is more compatible with the Java environment used.
Implementation has no fields and therefore thread-safe, but sub-classes are not necessarily thread-safe.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringContent encoding (for example"gzip") ornullfor none.private longContent length or less than zero if not known.private StringContent type ornullfor none.private StreamingContentStreaming content ornullfor no content. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidAdds a header to the HTTP request.abstract LowLevelHttpResponseexecute()Executes the request and returns a low-level HTTP response object.final StringReturns the content encoding (for example"gzip") ornullfor none.final longReturns the content length or less than zero if not known.final StringReturns the content type ornullfor none.final StreamingContentReturns the streaming content ornullfor no content.final voidsetContentEncoding(String contentEncoding) Sets the content encoding (for example"gzip") ornullfor none.final voidsetContentLength(long contentLength) Sets the content length or less than zero if not known.final voidsetContentType(String contentType) Sets the content type ornullfor none.final voidsetStreamingContent(StreamingContent streamingContent) Sets the streaming content ornullfor no content.voidsetTimeout(int connectTimeout, int readTimeout) Sets the connection and read timeouts.voidsetWriteTimeout(int writeTimeout) Sets the write timeout for POST/PUT requests.
-
Field Details
-
contentLength
private long contentLengthContent length or less than zero if not known. -
contentEncoding
Content encoding (for example"gzip") ornullfor none. -
contentType
Content type ornullfor none. -
streamingContent
Streaming content ornullfor no content.
-
-
Constructor Details
-
LowLevelHttpRequest
public LowLevelHttpRequest()
-
-
Method Details
-
addHeader
Adds a header to the HTTP request.Note that multiple headers of the same name need to be supported, in which case
addHeader(String, String)will be called for each instance of the header.- Parameters:
name- header namevalue- header value- Throws:
IOException
-
setContentLength
Sets the content length or less than zero if not known.Default value is
-1.- Throws:
IOException- I/O exception- Since:
- 1.14
-
getContentLength
public final long getContentLength()Returns the content length or less than zero if not known.- Since:
- 1.14
-
setContentEncoding
Sets the content encoding (for example"gzip") ornullfor none.- Throws:
IOException- I/O exception- Since:
- 1.14
-
getContentEncoding
Returns the content encoding (for example"gzip") ornullfor none.- Since:
- 1.14
-
setContentType
Sets the content type ornullfor none.- Throws:
IOException- I/O exception- Since:
- 1.14
-
getContentType
-
setStreamingContent
Sets the streaming content ornullfor no content.- Throws:
IOException- I/O exception- Since:
- 1.14
-
getStreamingContent
Returns the streaming content ornullfor no content.- Since:
- 1.14
-
setTimeout
Sets the connection and read timeouts.Default implementation does nothing, but subclasses should normally override.
- Parameters:
connectTimeout- timeout in milliseconds to establish a connection or0for an infinite timeoutreadTimeout- Timeout in milliseconds to read data from an established connection or0for an infinite timeout- Throws:
IOException- I/O exception- Since:
- 1.4
-
setWriteTimeout
Sets the write timeout for POST/PUT requests.Default implementation does nothing, but subclasses should normally override.
- Parameters:
writeTimeout- timeout in milliseconds to establish a connection or0for an infinite timeout- Throws:
IOException- I/O exception- Since:
- 1.27
-
execute
Executes the request and returns a low-level HTTP response object.- Throws:
IOException
-