aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http2.erl
AgeCommit message (Collapse)Author
2017-11-27Fix a few rfc7540 testsLoïc Hoguin
Cowboy takes a few shortcuts to avoid wasting resources when there is a protocol error. The RFC wants us to send a different error depending on the state of the stream at the time of the error, and for us to maintain the connection in cases where we would have to spend valuable resources to decode headers. In all these cases Cowboy will simply close the connection with an appropriate error.
2017-11-20Queue HTTP/2 trailers when there's still data in the bufferLoïc Hoguin
2017-11-15Add preliminary support for trailers in responsesLoïc Hoguin
This depends on changes in Cowlib that are only available on master.
2017-11-01Fix two edge cases for cowboy_req:stream_bodyLoïc Hoguin
Sending data of size 0 with the fin flag set resulted in nothing being sent to the client and still considering the response to be finished for HTTP/1.1. For both HTTP/1.1 and HTTP/2, the final chunk of body that is sent automatically by Cowboy at the end of a response that the user did not properly terminate was not passing through stream handlers. This resulted in issues like compression being incorrect. Some tests still fail under 20.1.3. They are due to recent zlib changes and should be fixed in a future patch release. Unfortunately it does not seem to be any 20.1 version that is safe to use for Cowboy, although some will work better than others.
2017-10-31Add some todosLoïc Hoguin
2017-10-29Add cowboy_req:inform/2,3Loïc Hoguin
User code can now send as many 1xx responses as necessary.
2017-10-25Introduce cowboy_req:sock/1 and cowboy_req:cert/1Loïc Hoguin
To obtain the local socket ip/port and the client TLS certificate, respectively.
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-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-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-08-21Tentative fix for out of order queued dataLoïc Hoguin
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-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-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-05Add inactivity_timeout and other options improvementsLoïc Hoguin
2017-04-18Get rid of stray messages when killing HTTP/2 request processesLoïc Hoguin
2017-04-18Make the default 204 response go through stream handlersLoïc Hoguin
2017-04-18Pass the HTTP/2 switch_protocol event to stream handlersLoïc Hoguin
To accomplish this the code for sending the 101 response was moved to the cowboy_http2 module.
2017-03-02Add more HTTP/2 tests for RFC7540 4.1 and 4.3Loïc Hoguin
2017-02-26Unknown HTTP/2 frames are ignoredLoïc Hoguin
2017-02-25Add many test cases covering RFC7540 4.2Loïc Hoguin
These tests cover frame sizes. It's mostly edge cases for sure (ie misbehaving clients and us having to reject them properly). I had these almost ready for a long time, so I'm glad I can push them out. This requires updating Cowlib too (we currently track master).
2017-02-05Remove or fix a small number of todo commentsLoïc Hoguin
One had the todo text fixed, another had the task to do done.
2017-02-05Fix sending of large files with HTTP/2Loïc Hoguin
Also finish implementing the relevant test, getting rid of todos.
2017-01-16Add support for multiple stream handlersLoïc Hoguin
The stream handlers can be specified using the protocol option 'stream_handlers'. It defaults to [cowboy_stream_h]. The cowboy_stream_h module currently does not forward the calls to further stream handlers. It feels like an edge case; usually we'd want to put our own handlers between the protocol code and the request process. I am therefore going to focus on other things for now. The various types and specifications for stream handlers have been updated and the cowboy_stream module can now be safely used as a behavior. The interface might change a little more, though. This commit does not include tests or documentation. They will follow separately.
2017-01-02Welcome to 2017Loïc Hoguin
2017-01-02Remaining Dialyzer fixesLoïc Hoguin
2016-08-10Make reply functions return ReqLoïc Hoguin
2016-08-10Add a lot of todosLoïc Hoguin
2016-08-10Add tests for responses and request body readingLoïc Hoguin
This is a large commit. The cowboy_req interface has largely changed, and will change a little more. It's possible that some examples or tests have not been converted to the new interface yet. The documentation has not yet been updated. All of this will be fixed in smaller subsequent commits. Gotta start somewhere...
2016-06-20Properly parse the host/port in HTTP/2Loïc Hoguin
2016-06-20Fix cowboy_req:peer/1Loïc Hoguin
2016-06-16Make sure a response is always sent with HTTP/2Loïc Hoguin
Previously only DATA was sent, with missing HEADERS.
2016-06-13Fix streaming HTTP/2 responsesLoïc Hoguin
Error reporting for connection processes has been improved, using a similar proc_lib hack as was done for the stream processes.
2016-06-08Fix request body reading in HTTP/2Loïc Hoguin
2016-06-06HTTP/2: Separate path and query componentsLoïc Hoguin
2016-06-06HTTP/2: Handle internal errorsLoïc Hoguin
2016-06-06HTTP/2: add support for sending filesLoïc Hoguin
2016-03-13Fix most remaining HTTP/2 handshake testsLoïc Hoguin
One category of tests involving the SETTINGS ack still fails. It is probably wise to leave these until more SETTINGS related tests are written.
2016-03-13Fix more HTTP/2 handshake test casesLoïc Hoguin
2016-03-12Add initial HTTP/1.1 Upgrade to HTTP/2Loïc Hoguin
The same edge cases that fail with other handshake methods also fail here (mostly bad preface/timeouts stuff). In addition, the HTTP2-Settings header contents are currently not checked and so the related edge case tests also fail.
2016-03-10Add the beginning of the rfc7540 test suiteLoïc Hoguin
Currently only testing handshake. Tests that pass currently involve no request/response. ALPN and prior knowledge support have some edge cases left to fix. HTTP/1.1 Upgrade has not been implemented yet.
2016-03-05Initial commit with connection/streamsLoïc Hoguin
Breaking changes with previous commit. This is a very large change, and I am giving up on making a single commit that fixes everything. More commits will follow slowly adding back features, introducing new tests and fixing the documentation. This change contains most of the work toward unifying the interface for handling both HTTP/1.1 and HTTP/2. HTTP/1.1 connections are now no longer 1 process per connection; instead by default 1 process per request is also created. This has a number of pros and cons. Because it has cons, we also allow users to use a lower-level API that acts on "streams" (requests/responses) directly at the connection process-level. If performance is a concern, one can always write a stream handler. The performance in this case will be even greater than with Cowboy 1, although all the special handlers are unavailable. When switching to Websocket, after the handler returns from init/2, Cowboy stops the stream and the Websocket protocol takes over the connection process. Websocket then calls websocket_init/2 for any additional initialization such as timers, because the process is different in init/2 and websocket_*/* functions. This however would allow us to use websocket_init/2 for sending messages on connect, instead of sending ourselves a message and be subject to races. Note that websocket_init/2 is optional. This is all a big change and while most of the tests pass, some functionality currently doesn't. SPDY is broken and will be removed soon in favor of HTTP/2. Automatic compression is currently disabled. The cowboy_req interface probably still have a few functions that need to be updated. The docs and examples do not refer the current functionality anymore. Everything will be fixed over time. Feedback is more than welcome. Open a ticket!