public abstract class LowLevelHttpRequest extends Object
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.
Constructor and Description |
---|
LowLevelHttpRequest() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addHeader(String name,
String value)
Adds a header to the HTTP request.
|
abstract LowLevelHttpResponse |
execute()
Executes the request and returns a low-level HTTP response object.
|
String |
getContentEncoding()
Returns the content encoding (for example
"gzip" ) or null for none. |
long |
getContentLength()
Returns the content length or less than zero if not known.
|
String |
getContentType()
Returns the content type or
null for none. |
StreamingContent |
getStreamingContent()
Returns the streaming content or
null for no content. |
void |
setContentEncoding(String contentEncoding)
Sets the content encoding (for example
"gzip" ) or null for none. |
void |
setContentLength(long contentLength)
Sets the content length or less than zero if not known.
|
void |
setContentType(String contentType)
Sets the content type or
null for none. |
void |
setStreamingContent(StreamingContent streamingContent)
Sets the streaming content or
null for no content. |
void |
setTimeout(int connectTimeout,
int readTimeout)
Sets the connection and read timeouts.
|
void |
setWriteTimeout(int writeTimeout)
Sets the write timeout for POST/PUT requests.
|
public abstract void addHeader(String name, String value) throws IOException
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.
name
- header namevalue
- header valueIOException
public final void setContentLength(long contentLength) throws IOException
Default value is -1
.
IOException
- I/O exceptionpublic final long getContentLength()
public final void setContentEncoding(String contentEncoding) throws IOException
"gzip"
) or null
for none.IOException
- I/O exceptionpublic final String getContentEncoding()
"gzip"
) or null
for none.public final void setContentType(String contentType) throws IOException
null
for none.IOException
- I/O exceptionpublic final String getContentType()
null
for none.public final void setStreamingContent(StreamingContent streamingContent) throws IOException
null
for no content.IOException
- I/O exceptionpublic final StreamingContent getStreamingContent()
null
for no content.public void setTimeout(int connectTimeout, int readTimeout) throws IOException
Default implementation does nothing, but subclasses should normally override.
connectTimeout
- timeout in milliseconds to establish a connection or 0
for an
infinite timeoutreadTimeout
- Timeout in milliseconds to read data from an established connection or
0
for an infinite timeoutIOException
- I/O exceptionpublic void setWriteTimeout(int writeTimeout) throws IOException
Default implementation does nothing, but subclasses should normally override.
writeTimeout
- timeout in milliseconds to establish a connection or 0
for an
infinite timeoutIOException
- I/O exceptionpublic abstract LowLevelHttpResponse execute() throws IOException
IOException
Copyright © 2011–2024 Google. All rights reserved.