xd1888 / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

Patch requests are not supported on Google App Engine #219

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Send an HTTP PATCH request from a Google App Engine application.
2. Get an exception stating that "PATCH" is not supported

What is the expected output? What do you see instead?
I would expect httplib2 to intercept the PATCH request and send a POST request 
instead with a "X-Http-Method-Override: PATCH" header to circumvent this 
limitation.
This won't be needed when this issue is fixed:
  http://code.google.com/p/googleappengine/issues/detail?id=6316

The attached patch takes a shot at solving this issue.

Original issue reported on code.google.com by ala...@google.com on 25 Jul 2012 at 4:53

Attachments:

GoogleCodeExporter commented 8 years ago
Update for a code update:

class AppEngineHttpConnection(httplib.HTTPConnection):
  ...
  def request(self, method, url, body=None, headers={}):
    if method.lower() in UNAUTHORIZED_METHODS:
      # No side-effects on provided headers.
      new_headers = {}
      new_headers.update(headers)
      new_headers[HTTP_METHOD_OVERRIDE_HEADER] = method
      method = HTTP_OVERRIDE_METHOD
      headers = new_headers
    super(AppEngineHttpConnection, self).request(method, url, body, headers)

since AppEngineHttpConnection now inherits from httplib.HTTPConnection

Original comment by dhermes@google.com on 2 Jan 2013 at 7:52