Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Google App Engine -- POST requests #70

Closed
swinton opened this issue May 11, 2012 · 7 comments
Closed

Support Google App Engine -- POST requests #70

swinton opened this issue May 11, 2012 · 7 comments

Comments

@swinton
Copy link

swinton commented May 11, 2012

I'm unable to re-open issue #61 for some reason, so reporting this separately.

It doesn't appear to work with POST requests:

import webapp2
import urllib3

class MainPage(webapp2.RequestHandler):
  def get(self):
      http = urllib3.PoolManager()
      r = http.request('GET', 'http://google.com/')
      r2 = http.request('GET', 'http://yahoo.com/')
      r3 = http.request('POST', 'http://www.example.com/')
      r4 = http.request('POST', 'http://www.example.com/', fields={"foo":"bar"})
      self.response.headers['Content-Type'] = 'text/plain'
      self.response.out.write(r.status)
      self.response.out.write(r2.status)
      self.response.out.write(r3.status)

app = webapp2.WSGIApplication([('/', MainPage)],
                              debug=True)

Traceback:

The API package 'remote_socket' or call 'Resolve()' was not found.
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1511, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1505, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1253, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 1077, in __call__
    return handler.dispatch()
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 547, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~megachunt/1.358837729334117339/urllib3_test.py", line 9, in get
    r3 = http.request('POST', 'http://www.example.com/')
  File "/base/data/home/apps/s~megachunt/1.358837729334117339/urllib3/request.py", line 71, in request
    **urlopen_kw)
  File "/base/data/home/apps/s~megachunt/1.358837729334117339/urllib3/request.py", line 119, in request_encode_body
    boundary=multipart_boundary)
  File "/base/data/home/apps/s~megachunt/1.358837729334117339/urllib3/filepost.py", line 57, in encode_multipart_formdata
    boundary = choose_boundary()
  File "/base/python27_runtime/python27_dist/lib/python2.7/mimetools.py", line 140, in choose_boundary
    hostid = socket.gethostbyname(socket.gethostname())
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 299, in gethostbyname
    return _Resolve(host, [AF_INET])[2][0]
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 251, in _Resolve
    canon, aliases, addresses = _ResolveName(name, families)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 269, in _ResolveName
    apiproxy_stub_map.MakeSyncCall('remote_socket', 'Resolve', request, reply)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 308, in MakeSyncCall
    rpc.CheckSuccess()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
    raise self.exception
CallNotFoundError: The API package 'remote_socket' or call 'Resolve()' was not found.
@shazow
Copy link
Member

shazow commented May 11, 2012

Ha, interesting, looks like AppEngine's mimetools.choose_boundary is broken. I'll take a look this weekend. :) Thanks for the report!

@shazow
Copy link
Member

shazow commented May 12, 2012

@shazow shazow closed this as completed in 4d477a6 May 12, 2012
@shazow
Copy link
Member

shazow commented May 12, 2012

@swinton Can you verify that it works now?

@swinton
Copy link
Author

swinton commented May 12, 2012

Yep, it's working now. Thanks for the quick turnaround :)

1 similar comment
@swinton
Copy link
Author

swinton commented May 12, 2012

Yep, it's working now. Thanks for the quick turnaround :)

@hbmartin
Copy link

hbmartin commented Aug 6, 2012

I'm still running into this problem on the latest version of GAE:

 File "/base/python27_runtime/python27_dist/lib/python2.7/mimetools.py", line 140, in choose_boundary
    hostid = socket.gethostbyname(socket.gethostname())
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 299, in gethostbyname
    return _Resolve(host, [AF_INET])[2][0]
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 251, in _Resolve
    canon, aliases, addresses = _ResolveName(name, families)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 269, in _ResolveName
    apiproxy_stub_map.MakeSyncCall('remote_socket', 'Resolve', request, reply)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 320, in MakeSyncCall
    rpc.CheckSuccess()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
    raise self.exception
CallNotFoundError: The API package 'remote_socket' or call 'Resolve()' was not found.

@shazow
Copy link
Member

shazow commented Aug 6, 2012

Hi @hbmartin, what version of urllib3 are you using?

The last couple of versions shouldn't be using mimetools (since v1.4), so this bug shouldn't exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants