jupyter-server-proxy icon indicating copy to clipboard operation
jupyter-server-proxy copied to clipboard

Can't proxy empty PUT requests

Open pepijndevos opened this issue 2 years ago • 2 comments

Bug description

I am proxying CouchDB and when a PUT request is issues without a body, a 500 error happens here:

https://github.com/tornadoweb/tornado/blob/00c9e0ae31a5a0d12e09109fb77ffe391bfe1131/tornado/simple_httpclient.py#L420-L423

One option would be to add PUT to the workaround that seems to be in place for POST

        body = self.request.body
        if not body:
            if self.request.method in  {'POST', 'PUT'}:
                body = b''
            else:
                body = None

Another option would be to simply set allow_nonstandard_methods.

Expected behaviour

HTTP requests are proxied no matter their content

Actual behaviour

Tornado implements "sanity checks" that throw an error if an empty body is passed in a PUT request.

How to reproduce

  1. Run an instance of CouchDB
  2. Run jupyter_server_proxy
  3. send a PUT request to /proxy/5984/somedatabase using any CouchDB API client or even curl.

pepijndevos avatar Feb 21 '22 14:02 pepijndevos

The description of HTTP PUT doesn't seem to forbid empty bodies. These may be unusual, but I wouldn't think nonstandard as tornado indicates.

If allow_nonstandard_methods were enabled generally, it would also permit methods other than GET, PUT, POST, etc. and I don't think we want that because we don't have proxy methods for them.

So to workaround tornado, I think it makes sense to be able to enable altering the request. I suppose this can be done along with POST as @betatim had done and as you suggest, or as a RewritableRequest in the same way we do RewritableResponse.

ryanlovett avatar Feb 28 '22 20:02 ryanlovett

Ok I've put in a PR that extends the POST workaround to include PUT.

pepijndevos avatar Mar 01 '22 18:03 pepijndevos

Resolved by #331

consideRatio avatar Sep 08 '22 07:09 consideRatio