Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Request headers should be case insensitive per RFC2616 #42

Closed
tomasgodoi opened this issue Aug 28, 2017 · 0 comments
Closed

Request headers should be case insensitive per RFC2616 #42

tomasgodoi opened this issue Aug 28, 2017 · 0 comments

Comments

@tomasgodoi
Copy link
Contributor

In fact, there's an assumption on AnkiConnect that the Content-Length header is on camel case.
That will break the behavior when you use a lib which doesn't write the headers like that.
That is the case when you use the node request (https://github.com/request/request) lib to call AnkiConnect.
I've wiresharked it and compared with a request made with Postman and found out it was the Content-Length header's fault, which was being sent as content-length.
AnkiConnect will use 0 as body length, bodyLength = int(headers.get(makeBytes('Content-Length'), 0)) (https://github.com/FooSoft/anki-connect/blob/master/AnkiConnect.py#L186) and will then return the default string AnkiConnect v.4 (due to if len(req.body) == 0: on https://github.com/FooSoft/anki-connect/blob/master/AnkiConnect.py#L259)
I'm already working on a Pull Request to make them case insensitive.

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

No branches or pull requests

1 participant