public abstract class LowLevelHttpRequest
extends java.lang.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(java.lang.String name,
java.lang.String value)
Adds a header to the HTTP request.
|
abstract LowLevelHttpResponse |
execute()
Executes the request and returns a low-level HTTP response object.
|
java.lang.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.
|
java.lang.String |
getContentType()
Returns the content type or
null for none. |
StreamingContent |
getStreamingContent()
Returns the streaming content or
null for no content. |
void |
setContentEncoding(java.lang.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(java.lang.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.
|
public abstract void addHeader(java.lang.String name, java.lang.String value) throws java.io.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 valuejava.io.IOException
public final void setContentLength(long contentLength) throws java.io.IOException
Default value is -1
.
java.io.IOException
- I/O exceptionpublic final long getContentLength()
public final void setContentEncoding(java.lang.String contentEncoding) throws java.io.IOException
"gzip"
) or null
for none.java.io.IOException
- I/O exceptionpublic final java.lang.String getContentEncoding()
"gzip"
) or null
for none.public final void setContentType(java.lang.String contentType) throws java.io.IOException
null
for none.java.io.IOException
- I/O exceptionpublic final java.lang.String getContentType()
null
for none.public final void setStreamingContent(StreamingContent streamingContent) throws java.io.IOException
null
for no content.java.io.IOException
- I/O exceptionpublic final StreamingContent getStreamingContent()
null
for no content.public void setTimeout(int connectTimeout, int readTimeout) throws java.io.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 timeoutjava.io.IOException
- I/O exceptionpublic abstract LowLevelHttpResponse execute() throws java.io.IOException
java.io.IOException
Copyright © 2011-2018 Google. All Rights Reserved.