aboutsummaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)Author
2017-10-23Fix a bug in HTTP/2 where connection gets closed prematurelyLoïc Hoguin
When the user code was sending a response fully without reading the request body, the connection could get closed when receiving DATA frames for that body. We now ask the client to stop sending data via a NO_ERROR RST_STREAM, and linger any stream that has been reset so that we can skip any pending frames from that stream. This fixes a number of intermittent failures in req_SUITE, which now passes reliably. In addition a small number of rfc7540_SUITE test cases have been corrected as they were incorrect.
2017-10-22Ensure stream terminate is called when switching protocolsLoïc Hoguin
2017-10-21Fix sending of final chunk in HTTP/1.1Loïc Hoguin
I broke this when fixing stream handlers earlier.
2017-10-21Fix stream handler state being discarded on terminateLoïc Hoguin
When we have to send a response before terminating a stream, we call info. The state returned by this info call was discarded when we called terminate after that. This commit fixes it. There are no tests for this, however the new metrics test in the next commit requires the correct behavior so this is ultimately covered.
2017-10-20Add a test for metrics with a request bodyLoïc Hoguin
2017-10-20Add experimental metrics stream handlerLoïc Hoguin
It collects metrics and passes them to a configurable callback once the stream terminates. It will be documented in a future release. More tests incoming.
2017-10-20Fix HTTP/1.1 stopping streams too earlyLoïc Hoguin
It is possible in some cases to move on to the next request without waiting, but that can be done as an optimization later on if necessary.
2017-10-03Make sure a path parsing error in the router gives a 400Loïc Hoguin
2017-10-02Fix cowboy:set_env when the env value is missingLoïc Hoguin
2017-10-02Fix infinite loop on incomplete multipart bodyJeffrey Griffin
I have amended a lot of changes from the original commit to make it behave as expected, including returning a 400 error. LH
2017-10-02Fix the documentation for the command flowLoïc Hoguin
2017-09-27Fix error response when constraint validation failsLoïc Hoguin
2017-09-27Ensure the behavior on stream handler crash is consistentLoïc Hoguin
Also corrects the lack of error response when HTTP/1.1 is used.
2017-09-25Cleanup various commentsLoïc Hoguin
2017-09-25Avoid some crashes when HTTP/2 streams flush their responseLoïc Hoguin
2017-09-25Move body length count to cowboy_stream_h instead of protocolsLoïc Hoguin
The documentation was correct, the code was not. This should make it easier to implement new protocols. Note that for HTTP/2 we will need to add some form of counting later on to check for malformed requests, but we can do simpler and just reduce from the expected length and then check if that's 0 when IsFin=fin.
2017-09-21Centralize stream handler error reporting in cowboy_streamLoïc Hoguin
2017-09-14Fix propagating the stacktrace on errors for OTP 19Loïc Hoguin
2017-09-14Rework the proc_lib_hackLoïc Hoguin
It is completely removed for connection processes, because assuming Cowboy is written properly this should bring us nothing anymore in 2.0. It is reworked for request processes, there we want to always propagate the stacktrace (including for exits) because we will print a report to help with debugging and proc_lib doesn't propagate it for exits. At the same time the initial callback for connection and request processes has been changed to connection_process and request_process, which should help with identifying processes when inspecting.
2017-09-14Improve how we detect request errorsLoïc Hoguin
When the request process exits with a {request_error, Reason, Human} exit reason, Cowboy will return a 400 status code instead of 500. Cowboy may also return a more specific status code depending on the error. Currently it may also return 408 or 413. This should prove to be more solid that looking inside the stack trace.
2017-09-05Remove transfer-encoding parsing from cowboy_reqLoïc Hoguin
The header never reaches this point.
2017-09-05Remove an unused variableLoïc Hoguin
2017-09-04Accept sendfile tuple with 0 length in cowboy_reqLoïc Hoguin
This will result in no data being sent. It's simply easier to do this than to have to handle 0 size cases in user code.
2017-09-04Fix more documentation todosLoïc Hoguin
I have decided not to include a manual page for cowboy_stream_h at this point because it clashes with the cowboy_stream manual page. This decision will be revisited in the future.
2017-08-21Tentative fix for out of order queued dataLoïc Hoguin
2017-08-21Properly clean up timers when terminatingLoïc Hoguin
2017-08-08Add missing cowboy_children moduleLoïc Hoguin
My bad! Still new at this.
2017-08-08Implement the shutdown timeout for request processesLoïc Hoguin
This should work very similar to normal supervisors, in particular during the shutdown sequence when the connection process goes down or switches to Websocket. Processes that need to enforce the shutdown timeout will be required to trap exits, just like in a supervisor. In a vanilla Cowboy, this only matters at connection shutdown, as Cowboy will otherwise wait for the request process to be down before stopping the stream. Tests are currently missing.
2017-07-26Fix HTTP/2 server pushLoïc Hoguin
Cowboy was encoding the headers then decoding them when initializing the request. The problem is that the encoding and decoding contexts are not the same. Now, Cowboy will directly use the headers it received in the push command for the new request. This is also more efficient. I am surprised it worked at all considering the issue.
2017-07-15Req Body length can be a non_neg_integer or infinitySteven Magelowitz
2017-07-12Catch more 400 errorsLoïc Hoguin
2017-07-01Aggregate validation errors and pass them in exceptionLoïc Hoguin
2017-06-28Fix wrong percent encoding in a router testLoïc Hoguin
2017-06-28Remove the cyrillic latin1 testLoïc Hoguin
These characters are not allowed in URI paths.
2017-06-28Fix unit tests in cowboy_router following interface changesLoïc Hoguin
2017-06-28Improve the interface for constraintsLoïc Hoguin
There are two important changes in this commit. Constraints are now producing an error tuple. This error tuple in turn can be provided to a function for formatting a human readable error message. Both the error tuple and the formatting code are controlled by and part of the constraint function. Constraints now also implement the reverse operation. When constraint functions only validate, the reverse operation will be the same as the forward operation. When they also do some conversion then the reverse operation will reverse it. Since constraints are now performing 3 different operations (forward, reverse and format_error), they now take the form of a function accepting two separate arguments. The operation is the first argument. In addition, the return value was changed to take the form of {ok, Value} | {error, Reason}. The value must be returned as-is if it was not modified.
2017-06-09Make cowboy_req:read_part return multipart headers as mapLoïc Hoguin
2017-06-07Remove NumAcceptors argument from start_clear/tlsLoïc Hoguin
They are now cowboy:start_clear/3 and cowboy:start_tls/3. The NumAcceptors argument can be specified via the num_acceptor transport option. Ranch has been updated to 1.4.0 to that effect.
2017-06-02Fix terminate not being called on connection close in HTTP/1.1Loïc Hoguin
Introduces the new stream_handler_SUITE test suite. More cases will be added later on.
2017-05-31Don't terminate streams that were already terminatedLoïc Hoguin
This and the issues in the last two commits were reported by leo2007 on IRC.
2017-05-31Fix bad accounting of HTTP/2 windowsLoïc Hoguin
The previous code was incorrectly substracting the maximum frame size we could send when the data we were actually sending was much lower.
2017-05-31Apply the received SETTINGS frameLoïc Hoguin
2017-05-28Introduce the req_filter Websocket optionLoïc Hoguin
This option allows customizing the compacting of the Req object when using Websocket. By default it will keep most public fields excluding headers of course, since those can be large.
2017-05-23Add many tests for RFC7540 5.1 and 5.1.1 and related fixesLoïc Hoguin
2017-05-19Preliminary h2 flow control supportLoïc Hoguin
Existing tests pass. A number of things remain to be done. Has only been tested with Gun so far. Feedback welcome!
2017-05-07make set_env working with maps.Alexandre Snarskii
2017-05-05length can be a non_neg_integer or infinitySteven Magelowitz
2017-05-05Properly handle 101 upgrade responses for WebsocketLoïc Hoguin
2017-05-05Add inactivity_timeout and other options improvementsLoïc Hoguin
2017-05-03Kill all children processes when terminating the connectionLoïc Hoguin
This is a more or less temporary solution to an existing problem. In the future we will need to enforce a shutdown timeout for these processes.