Package com.google.api.client.http
Class LowLevelHttpRequest
java.lang.Object
com.google.api.client.http.LowLevelHttpRequest
- Direct Known Subclasses:
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 String
Content encoding (for example"gzip"
) ornull
for none.private long
Content length or less than zero if not known.private String
Content type ornull
for none.private StreamingContent
Streaming content ornull
for no content. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
Adds a header to the HTTP request.abstract LowLevelHttpResponse
execute()
Executes the request and returns a low-level HTTP response object.final String
Returns the content encoding (for example"gzip"
) ornull
for none.final long
Returns the content length or less than zero if not known.final String
Returns the content type ornull
for none.final StreamingContent
Returns the streaming content ornull
for no content.final void
setContentEncoding
(String contentEncoding) Sets the content encoding (for example"gzip"
) ornull
for none.final void
setContentLength
(long contentLength) Sets the content length or less than zero if not known.final void
setContentType
(String contentType) Sets the content type ornull
for none.final void
setStreamingContent
(StreamingContent streamingContent) Sets the streaming content ornull
for no content.void
setTimeout
(int connectTimeout, int readTimeout) Sets the connection and read timeouts.
-
Field Details
-
contentLength
private long contentLengthContent length or less than zero if not known. -
contentEncoding
Content encoding (for example"gzip"
) ornull
for none. -
contentType
Content type ornull
for none. -
streamingContent
Streaming content ornull
for 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(java.lang.String, java.lang.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"
) ornull
for none.- Throws:
IOException
- I/O exception- Since:
- 1.14
-
getContentEncoding
Returns the content encoding (for example"gzip"
) ornull
for none.- Since:
- 1.14
-
setContentType
Sets the content type ornull
for none.- Throws:
IOException
- I/O exception- Since:
- 1.14
-
getContentType
Returns the content type ornull
for none.- Since:
- 1.14
-
setStreamingContent
Sets the streaming content ornull
for no content.- Throws:
IOException
- I/O exception- Since:
- 1.14
-
getStreamingContent
Returns the streaming content ornull
for 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 or0
for an infinite timeoutreadTimeout
- Timeout in milliseconds to read data from an established connection or0
for an infinite timeout- Throws:
IOException
- I/O exception- Since:
- 1.4
-
execute
Executes the request and returns a low-level HTTP response object.- Throws:
IOException
-