Class NetHttpRequest
- java.lang.Object
-
- com.google.api.client.http.LowLevelHttpRequest
-
- com.google.api.client.http.javanet.NetHttpRequest
-
final class NetHttpRequest extends LowLevelHttpRequest
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
NetHttpRequest.DefaultOutputWriter
(package private) static interface
NetHttpRequest.OutputWriter
-
Field Summary
Fields Modifier and Type Field Description private java.net.HttpURLConnection
connection
private static NetHttpRequest.OutputWriter
DEFAULT_CONNECTION_WRITER
private int
writeTimeout
-
Constructor Summary
Constructors Constructor Description NetHttpRequest(java.net.HttpURLConnection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHeader(java.lang.String name, java.lang.String value)
Adds a header to the HTTP request.LowLevelHttpResponse
execute()
Executes the request and returns a low-level HTTP response object.(package private) LowLevelHttpResponse
execute(NetHttpRequest.OutputWriter outputWriter)
(package private) java.lang.String
getRequestProperty(java.lang.String name)
private boolean
hasResponse(java.net.HttpURLConnection connection)
void
setTimeout(int connectTimeout, int readTimeout)
Sets the connection and read timeouts.void
setWriteTimeout(int writeTimeout)
Sets the write timeout for POST/PUT requests.private void
writeContentToOutputStream(NetHttpRequest.OutputWriter outputWriter, java.io.OutputStream out)
-
Methods inherited from class com.google.api.client.http.LowLevelHttpRequest
getContentEncoding, getContentLength, getContentType, getStreamingContent, setContentEncoding, setContentLength, setContentType, setStreamingContent
-
-
-
-
Field Detail
-
connection
private final java.net.HttpURLConnection connection
-
writeTimeout
private int writeTimeout
-
DEFAULT_CONNECTION_WRITER
private static final NetHttpRequest.OutputWriter DEFAULT_CONNECTION_WRITER
-
-
Method Detail
-
addHeader
public void addHeader(java.lang.String name, java.lang.String value)
Description copied from class:LowLevelHttpRequest
Adds a header to the HTTP request.Note that multiple headers of the same name need to be supported, in which case
LowLevelHttpRequest.addHeader(java.lang.String, java.lang.String)
will be called for each instance of the header.- Specified by:
addHeader
in classLowLevelHttpRequest
- Parameters:
name
- header namevalue
- header value
-
getRequestProperty
java.lang.String getRequestProperty(java.lang.String name)
-
setTimeout
public void setTimeout(int connectTimeout, int readTimeout)
Description copied from class:LowLevelHttpRequest
Sets the connection and read timeouts.Default implementation does nothing, but subclasses should normally override.
- Overrides:
setTimeout
in classLowLevelHttpRequest
- 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
-
setWriteTimeout
public void setWriteTimeout(int writeTimeout) throws java.io.IOException
Description copied from class:LowLevelHttpRequest
Sets the write timeout for POST/PUT requests.Default implementation does nothing, but subclasses should normally override.
- Overrides:
setWriteTimeout
in classLowLevelHttpRequest
- Parameters:
writeTimeout
- timeout in milliseconds to establish a connection or0
for an infinite timeout- Throws:
java.io.IOException
- I/O exception
-
execute
public LowLevelHttpResponse execute() throws java.io.IOException
Description copied from class:LowLevelHttpRequest
Executes the request and returns a low-level HTTP response object.- Specified by:
execute
in classLowLevelHttpRequest
- Throws:
java.io.IOException
-
execute
LowLevelHttpResponse execute(NetHttpRequest.OutputWriter outputWriter) throws java.io.IOException
- Throws:
java.io.IOException
-
hasResponse
private boolean hasResponse(java.net.HttpURLConnection connection)
-
writeContentToOutputStream
private void writeContentToOutputStream(NetHttpRequest.OutputWriter outputWriter, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
-