Replies: 3 comments 2 replies
-
This is a great set of questions, and likely a bunch of distinct issues for the http implementation. Some of these are supported, some are not. I'll answer each of these to the best of my knowledge, but would be extremely interested to learn of any inaccuracies or provable bad behavior on the part of the http layer. In general, if the http layer encounters something that does not conform to protocol, it will drop the tcp connection gracefully. Sometimes if it's possible, it will try to send a 500 error.
Trillium currently treats compression as a distinct concern from the http implementation. [
I believe this is fully handled, and should be graceful in all circumstances
If the tcp connection is closed, we will not send any content. We will, however, finish running handlers.
There is not currently any explicit protection against this, and it's worth looking into the behavior. It might slow down other requests, but I don't think it would crash trillium or anything like that.
I believe this should be entirely fine
Trillium currently support a fairly conservative maximum of 2kb of request headers and a maximum of 128 headers. When those are exceeded, we send a 500 and log a descriptive error. These should eventually be user-configurable, and I can prioritize that if it's important to anyone.
The header parsing is currently handled by httparse, and I have every confidence this handles this behavior according to spec
If the request content-length is longer than the provided bytes, I think trillium currently will return the available bytes. This probably should be an error, however.
If the body is longer than the content-length, we will read the content-length number of bytes, respond to the request, and treat the remaining bytes (buffered or not) as the start of a subsequent pipelined request.
If there is not a chunk boundary where it is expected, we will return an error in the handler code that is attempting to read the request body. Application code can determine how to handle this.
This may degrade performance but I do not think there is any further issue with it. We will read however many bytes that the networking stack has available for us, up to the number of bytes we have allocated to read. Many single byte chunks will result in slower throughput but no more allocation.
there are no hashmaps or hashsets in trillium's server implementation
header parsing is handled by httparse
I'm not sure about this one, but we don't assume utf8 anywhere in library code, and application code will receive an Err variant if they attempt to read a request body that is not utf8 as a string.
Could you clarify what you mean by add them? Do you mean a test suite for pathological requests? I'd love to have this, and looked around a lot for something like this when I was working on the http layer. In my opinion, there's no reason for this sort of "pathological http server test suite" to be tied to any particular server implementation. Ideally, there would be a cli tool that could be run against a port and that hammers the server with each of these malformed request types. I'd love to write that, but it's not a particularly high priority for me currently unless someone sponsors me to do it. |
Beta Was this translation helpful? Give feedback.
-
Yes, I think Trillium needs tests for all of these behaviors. Each test should start a Trilium server and communicate with it over TCP. Without these tests, I will be testing Trillium in production. I started writing a library like Trillium some time ago, as I was learning Rust. Here is a test suite: Related: https://github.com/httpwg/wiki/wiki/HTTP-Testing-Resources |
Beta Was this translation helpful? Give feedback.
-
Related: https://github.com/hyperium/hyper/blob/master/tests/server.rs |
Beta Was this translation helpful? Give feedback.
-
A web server needs tests for all kinds of bad behavior:
I looked around the code and couldn't find these. Is there something on the roadmap to add them?
Beta Was this translation helpful? Give feedback.
All reactions