Populate headers for HTTP OPTIONS requests#1062
Conversation
|
The automatic test seems to hang somewhere, all automatic builds are stopped there without finishing the test. |
It is hanging on Line 2047 in 584560f Which is testing an invalid HTTP packet. Causing the parser to report an error to do_read() here Crow/include/crow/http_connection.h Line 492 in 584560f Which hangs. The unit test never hang before because the OPTIONS packet would stop parsing early at the url stage. From reading the unit tests file I believe this unit test was not designed to test an invalid packet. Correcting the packet causes that specific unit test to no longer hang. That being said, now one of the tests fail, so I will work on that. |
|
Turns out it was the same thing as the previous comment. The unit test in question was failing because the result it was getting was empty. It was empty because an error was thrown ( The unit test never failed before because the OPTIONS packet would stop parsing early at the url stage. |
|
@gittiver I believe this is ready for your review once again. :) |
…ockets for websocket endpoints
|
^ rebased onto master |
When running middleware for an HTTP OPTIONS request (for CORS for example). There is a bug where the headers from the request are not populated. Also referenced here: #721 (comment).
The reason this occurs is because the parser will parse the URL first (before the headers) and in the
handle_urlfunction, it will end parsing the request early, returning the response, and triggering the middleware.The proposed changes will prevent us from exiting early in the
handle_urlfunction and instead exit early at thehandle_headersfunction, which is executed when all of the headers have finished parsing.It is also important to note that OPTIONS requests are fully handled within crow, and crow will never call a user defined OPTIONS route.
I believe this Fixes #721.