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

PUT and DELETE requests not supported #7

Open
GoogleCodeExporter opened this issue Sep 10, 2015 · 1 comment
Open

PUT and DELETE requests not supported #7

GoogleCodeExporter opened this issue Sep 10, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Start proxy
2. Make an HTTP PUT or DELETE request through proxy

What is the expected output? What do you see instead?

Expected proxying as with POST. Got the following error:

2014-02-13T22:51:51.793047+00:00 app[web.1]: Traceback (most recent call last):
2014-02-13T22:51:51.793047+00:00 app[web.1]:   File 
"/usr/local/lib/python2.7/SocketServer.py", line 582, in process_request_thread
2014-02-13T22:51:51.793047+00:00 app[web.1]:     self.finish_request(request, 
client_address)
2014-02-13T22:51:51.793047+00:00 app[web.1]:   File 
"/usr/local/lib/python2.7/SocketServer.py", line 323, in finish_request
2014-02-13T22:51:51.793047+00:00 app[web.1]:     
self.RequestHandlerClass(request, client_address, self)
2014-02-13T22:51:51.793047+00:00 app[web.1]:   File "/app/proxpy/core.py", line 
54, in __init__
2014-02-13T22:51:51.793047+00:00 app[web.1]:     
SocketServer.StreamRequestHandler.__init__(self, request, client_address, 
server)
2014-02-13T22:51:51.794594+00:00 app[web.1]:   File 
"/usr/local/lib/python2.7/SocketServer.py", line 639, in __init__
2014-02-13T22:51:51.794671+00:00 app[web.1]:     self.handle()
2014-02-13T22:51:51.794671+00:00 app[web.1]:   File "/app/proxpy/core.py", line 
128, in handle
2014-02-13T22:51:51.794671+00:00 app[web.1]:     if req.getMethod() == 
HTTPRequest.METHOD_GET:
2014-02-13T22:51:51.794671+00:00 app[web.1]:   File "/app/proxpy/http.py", line 
272, in getMethod
2014-02-13T22:51:51.794671+00:00 app[web.1]:     return r
2014-02-13T22:51:51.794671+00:00 app[web.1]: UnboundLocalError: local variable 
'r' referenced before assignment

The error occurs because `getMethod` does not account for these HTTP verbs 
(presumably because PUT and DELETE need more code):

    def getMethod(self):
        m = self.method.lower()
        if   m == "get":     r = HTTPRequest.METHOD_GET
        elif m == "post":    r = HTTPRequest.METHOD_POST
        elif m == "head":    r = HTTPRequest.METHOD_HEAD
        elif m == "options": r = HTTPRequest.METHOD_OPTIONS
        elif m == "connect": r = HTTPRequest.METHOD_CONNECT
    elif m == "unknown": r = HTTPRequest.METHOD_UNKNOWN
        return r


What version of the product are you using? On what operating system?

r29 on Ubuntu 10.04, with Python 2.7.2



Original issue reported on code.google.com by mac...@heroku.com on 14 Feb 2014 at 12:24

@GoogleCodeExporter
Copy link
Author

I added the PUT method (see attached file). I didn't test it thoroughly, but 
seems to work ok.

The DELETE method should be quite similar.

Original comment by rvantklo...@gmail.com on 5 Jul 2015 at 9:08

Attachments:

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

No branches or pull requests

1 participant