com.google.api.client.googleapis
Class MethodOverride

java.lang.Object
  extended by com.google.api.client.googleapis.MethodOverride
All Implemented Interfaces:
HttpExecuteInterceptor, HttpRequestInitializer

public final class MethodOverride
extends Object
implements HttpExecuteInterceptor, HttpRequestInitializer

HTTP request execute interceptor for Google API's that wraps HTTP requests -- other than GET or POST -- inside of a POST request and uses "X-HTTP-Method-Override" header to specify the actual HTTP method.

Use this 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(EnumSet) constructor instead to specify additional methods to override. GET and POST are never overridden.

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.

Since:
1.4
Author:
Yaniv Inbar

Constructor Summary
MethodOverride()
          Only overrides HTTP methods that the HTTP transport does not support.
MethodOverride(EnumSet<HttpMethod> override)
          Specifies the HTTP methods to override.
 
Method Summary
 void initialize(HttpRequest request)
           
 void intercept(HttpRequest request)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodOverride

public MethodOverride()
Only overrides HTTP methods that the HTTP transport does not support.


MethodOverride

public MethodOverride(EnumSet<HttpMethod> override)
Specifies the HTTP methods to override.

Parameters:
override - HTTP methods supported by the HTTP transport that nevertheless need to be overridden
Method Detail

initialize

public void initialize(HttpRequest request)
Specified by:
initialize in interface HttpRequestInitializer

intercept

public void intercept(HttpRequest request)
Specified by:
intercept in interface HttpExecuteInterceptor


Copyright © 2010-2012 Google. All Rights Reserved.