public final class MethodOverride extends Object implements HttpExecuteInterceptor, HttpRequestInitializer
HEADER
header to specify the actual HTTP method.
Use this for example for an HTTP transport that doesn't support PATCH like
NetHttpTransport
or UrlFetchTransport
. By default, only the methods not supported
by the transport will be overridden. When running behind a firewall that does not support certain
verbs like PATCH, use the MethodOverride.Builder.setOverrideAllMethods(boolean)
constructor instead to specify to override all methods. POST is never overridden.
This class also allows GET requests with a long URL (> 2048 chars) to be instead sent using method override as a POST request.
Sample usage, taking advantage that this class implements HttpRequestInitializer
:
public static HttpRequestFactory createRequestFactory(HttpTransport transport) { return transport.createRequestFactory(new MethodOverride()); }
If you have a custom request initializer, take a look at the sample usage for
HttpExecuteInterceptor
, which this class also implements.
Modifier and Type | Class and Description |
---|---|
static class |
MethodOverride.Builder
Builder for
MethodOverride . |
Modifier and Type | Field and Description |
---|---|
static String |
HEADER
Name of the method override header.
|
Constructor and Description |
---|
MethodOverride()
Only overrides HTTP methods that the HTTP transport does not support.
|
Modifier and Type | Method and Description |
---|---|
void |
initialize(HttpRequest request) |
void |
intercept(HttpRequest request) |
public static final String HEADER
public MethodOverride()
public void initialize(HttpRequest request)
initialize
in interface HttpRequestInitializer
public void intercept(HttpRequest request) throws IOException
intercept
in interface HttpExecuteInterceptor
IOException
Copyright © 2010–2019 Google. All rights reserved.