public class MockHttpTransport extends HttpTransport
HttpTransport
.
Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the HTTP transport.
Upgrade warning: in prior version 1.11 this used HttpMethod
to specify the set of
supported methods, but now it uses a String
instead to allow for arbitrary methods to be
specified.
Modifier and Type | Class and Description |
---|---|
static class |
MockHttpTransport.Builder
Builder for
MockHttpTransport . |
Modifier | Constructor and Description |
---|---|
|
MockHttpTransport() |
protected |
MockHttpTransport(Set<String> supportedMethods) |
Modifier and Type | Method and Description |
---|---|
LowLevelHttpRequest |
buildDeleteRequest(String url)
Deprecated.
|
static MockHttpTransport.Builder |
builder()
Returns an instance of a new builder.
|
LowLevelHttpRequest |
buildGetRequest(String url)
Deprecated.
|
LowLevelHttpRequest |
buildHeadRequest(String url)
Deprecated.
|
LowLevelHttpRequest |
buildPatchRequest(String url)
Deprecated.
|
LowLevelHttpRequest |
buildPostRequest(String url)
Deprecated.
|
LowLevelHttpRequest |
buildPutRequest(String url)
Deprecated.
|
protected LowLevelHttpRequest |
buildRequest(String method,
String url)
Builds a low level HTTP request for the given HTTP method.
|
Set<String> |
getSupportedMethods()
Returns the unmodifiable set of supported HTTP methods or
null to specify that all
methods are supported. |
boolean |
supportsHead()
Deprecated.
|
boolean |
supportsMethod(String method)
Returns whether a specified HTTP method is supported by this transport.
|
boolean |
supportsPatch()
Deprecated.
|
createRequestFactory, createRequestFactory, shutdown
public boolean supportsMethod(String method) throws IOException
HttpTransport
Default implementation returns true if and only if the request method is "DELETE"
,
"GET"
, "POST"
, or "PUT"
. Subclasses should override.
supportsMethod
in class HttpTransport
method
- HTTP methodIOException
- I/O exceptionprotected LowLevelHttpRequest buildRequest(String method, String url) throws IOException
HttpTransport
Warning: for backwards compatibility, in version 1.12 a default implementation that throws an
IllegalArgumentException
is provided, but it will be made abstract in the next version
1.13.
buildRequest
in class HttpTransport
method
- HTTP methodurl
- URLIOException
- I/O exceptionpublic final Set<String> getSupportedMethods()
null
to specify that all
methods are supported.@Deprecated public LowLevelHttpRequest buildDeleteRequest(String url) throws IOException
HttpTransport
DELETE
request.
Default implementation calls HttpTransport.buildRequest()
.
buildDeleteRequest
in class HttpTransport
url
- URLIOException
@Deprecated public LowLevelHttpRequest buildGetRequest(String url) throws IOException
HttpTransport
GET
request.
Default implementation calls HttpTransport.buildRequest()
.
buildGetRequest
in class HttpTransport
url
- URLIOException
@Deprecated public LowLevelHttpRequest buildHeadRequest(String url) throws IOException
HttpTransport
HEAD
request.
Won't be called if HttpTransport.supportsHead()
returns false
.
Default implementation calls HttpTransport.buildRequest()
.
Upgrade warning: in prior version it threw an UnsupportedOperationException
by
default}.
buildHeadRequest
in class HttpTransport
url
- URLIOException
@Deprecated public LowLevelHttpRequest buildPatchRequest(String url) throws IOException
HttpTransport
PATCH
request.
Won't be called if HttpTransport.supportsPatch()
returns false
.
Default implementation calls HttpTransport.buildRequest()
.
Upgrade warning: in prior version it threw an UnsupportedOperationException
by
default}.
buildPatchRequest
in class HttpTransport
url
- URLIOException
@Deprecated public LowLevelHttpRequest buildPostRequest(String url) throws IOException
HttpTransport
POST
request.
Default implementation calls HttpTransport.buildRequest()
.
buildPostRequest
in class HttpTransport
url
- URLIOException
@Deprecated public LowLevelHttpRequest buildPutRequest(String url) throws IOException
HttpTransport
PUT
request.
Default implementation calls HttpTransport.buildRequest()
.
buildPutRequest
in class HttpTransport
url
- URLIOException
@Deprecated public boolean supportsHead() throws IOException
HttpTransport
HEAD
request method.
Default implementation calls HttpTransport.supportsMethod(java.lang.String)
.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
supportsHead
in class HttpTransport
IOException
@Deprecated public boolean supportsPatch() throws IOException
HttpTransport
PATCH
request method.
Default implementation calls HttpTransport.supportsMethod(java.lang.String)
.
Upgrade warning: this method now throws an IOException
. In prior version 1.11 it did
not throw an exception.
supportsPatch
in class HttpTransport
IOException
public static MockHttpTransport.Builder builder()
Copyright © 2011-2012 Google. All Rights Reserved.