Issue #201: /_admin/api method create_user responds with Content-Length field twice
Reported by: | Krzysztof Słonka |
State: | resolved |
Created on: | 2016-03-28 09:57 |
Updated on: | 2016-05-05 14:00 |
Description
Hello,
doing a http request like this:
POST /_admin/api HTTP/1.1 host: 127.0.0.1:8080 accept: application/json content-type: application/json Content-Length: 317 Connection: close {"id":"bdb52f80-f4c9-11e5-8eed-3525bf27bc51","api_key":"__REMOVED_KEY__","method":"create_user","args":{"username":"k2","email":"REMOVED+8@gmail.com","password":"__REMOVED_PASSWORD__","firstname":"X","lastname":"X"}}
Produces a response like this:
HTTP/1.1 200 OK Cache-Control: no-cache Connection: close Content-Length: 297 Content-Length: 297 Content-Type: application/json Date: Mon, 28 Mar 2016 09:49:08 GMT Pragma: no-cache Server: waitress {"error": null, "id": "bdb52f80-f4c9-11e5-8eed-3525bf27bc51", "result": {"msg": "created new user `k2`", "user": {"username": "k2", "user_id": 8, "firstname": "X", "admin": false, "lastname": "X", "emails": ["REMOVED+8@gmail.com"], "active": true, "email": "REMOVED+8@gmail.com"}}}
The response has 'Content-Length: 297' twice, which causes node http parser to fail with:
{ [Error: Parse Error] bytesParsed: 95, code: 'HPE_UNEXPECTED_CONTENT_LENGTH' }
If I modify the response myself and remove one instance of 'Content-Length' then everything is fine.
I've installed kallithea 0.3.1 from pip (using this tutorial https://pythonhosted.org/Kallithea/installation.html#installing-a-released-version-in-a-virtualenv)
Attachments
Comments
Comment by Mads Kiilerich, on 2016-03-29 11:43
As a temporary workaround, you can edit kallithea/controllers/api/__init__.py
and just remove the extra Content-Length header in line 243.
Comment by Krzysztof Słonka, on 2016-03-29 12:13
Is this going to break anything else? Why is it only temporary?
Comment by Mads Kiilerich, on 2016-03-29 12:32
You can do it temporarily until next release. The next release will probably do just that.
Comment by Krzysztof Słonka, on 2016-05-05 11:49
Comment by Mads Kiilerich, on 2016-05-05 14:00
Fixed in 0.3.2