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.
Modifier and Type | Class and Description |
---|---|
static class |
MockHttpTransport.Builder
Builder for
MockHttpTransport . |
Modifier | Constructor and Description |
---|---|
|
MockHttpTransport() |
protected |
MockHttpTransport(MockHttpTransport.Builder builder) |
protected |
MockHttpTransport(Set<String> supportedMethods)
Deprecated.
(scheduled to be removed in 1.15) Use
MockHttpTransport(Builder) |
Modifier and Type | Method and Description |
---|---|
static MockHttpTransport.Builder |
builder()
Returns an instance of a new builder.
|
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 |
supportsMethod(String method)
Returns whether a specified HTTP method is supported by this transport.
|
createRequestFactory, createRequestFactory, shutdown
public MockHttpTransport()
protected MockHttpTransport(MockHttpTransport.Builder builder)
builder
- builder@Deprecated protected MockHttpTransport(Set<String> supportedMethods)
MockHttpTransport(Builder)
supportedMethods
- supported HTTP methods or null
to specify that all methods are
supportedpublic 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 exceptionpublic LowLevelHttpRequest buildRequest(String method, String url) throws IOException
Upgrade warning: in prior version 1.13 this method was protected, but starting with version 1.14 this method is public.
buildRequest
in class HttpTransport
method
- HTTP methodurl
- URLIOException
public final Set<String> getSupportedMethods()
null
to specify that all
methods are supported.public static MockHttpTransport.Builder builder()
Copyright © 2011-2013 Google. All Rights Reserved.