@Beta public class MockHttpTransport extends HttpTransport
Beta
HttpTransport
.
Implementation is thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the HTTP transport.
Modifier and Type | Class | Description |
---|---|---|
static class |
MockHttpTransport.Builder |
Modifier | Constructor | Description |
---|---|---|
|
MockHttpTransport() |
|
protected |
MockHttpTransport(MockHttpTransport.Builder builder) |
Modifier and Type | Method | Description |
---|---|---|
static MockHttpTransport.Builder |
builder() |
Deprecated.
(to be removed in the future) Use
Builder() instead.
|
LowLevelHttpRequest |
buildRequest(String method,
String url) |
Builds a low level HTTP request for the given HTTP method.
|
MockLowLevelHttpRequest |
getLowLevelHttpRequest() |
Returns the
MockLowLevelHttpRequest that is associated with this MockHttpTransport.Builder ,
or null if no such instance exists. |
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
- builderpublic 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
HttpTransport
buildRequest
in class HttpTransport
method
- HTTP methodurl
- URLIOException
public final Set<String> getSupportedMethods()
null
to specify that all
methods are supported.public final MockLowLevelHttpRequest getLowLevelHttpRequest()
MockLowLevelHttpRequest
that is associated with this MockHttpTransport.Builder
,
or null
if no such instance exists.@Deprecated public static MockHttpTransport.Builder builder()
Builder()
instead.
Copyright © 2011–2019 Google. All rights reserved.