jupyter-server-proxy
jupyter-server-proxy copied to clipboard
Can't proxy empty PUT requests
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
- Run an instance of CouchDB
- Run jupyter_server_proxy
- send a PUT request to
/proxy/5984/somedatabaseusing any CouchDB API client or even curl.
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.
Ok I've put in a PR that extends the POST workaround to include PUT.
Resolved by #331