-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Heph-HTTP crate #461
Merged
Merged
Add Heph-HTTP crate #461
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This current commit is rather bare-bones. It does have a (barely functional) HttpServer which can receive HTTP requests and send HTTP responses. But plenty of things are missing (not to mention tests).
We'll mostly use a 'static lifetime, e.g. in Headers, but a short lifetime can be used in various places when we're actually borrowing data. For example in the Iterator implementation for Headers and Headers::get, neither now needs to clone the HeaderName and instead lets the name be borrowed. This also adds another lifetime to Headers, now 'n and 'v for the name and value.
Also fixes HeaderName::from_str to actually match (case-insensitive) the known static headers.
This allow the implementation str to borrow the value, rather than making an allocation.
Also some tests for the is_* functions.
This removes two dependencies: socket2 and getrandom, neither are needed anymore. Also remove a number of unused imports.
Also expands the documentation and adds tests.
Returns the method as string.
The "Date" header, should be send with responses.
Returns major/minor version.
This adds a dependency on the httpdate crate.
Returns a static reason phrase, if known.
This know includes all headers currently registered at https://www.iana.org/assignments/message-headers/message-headers.xhtml.
This commit adds four body types: * EmptyBody: no/empty body. * OneshotBody: body consisting of a single slice of bytes (&[u8]). * StreamingBody: body that is streaming, with a known length. * ChunkedBody: body that is streaming, with a unknown length. This uses HTTP chunked encoding to transfer the body. The ChunkedBody body however doesn't have an implementation yet.
Since it's now used in both Bytes and BytesVectored.
Still left to do is dropping an unread chunked Body, ensuring that the bytes are all removed from the connection.
Connection::respond now accepts a reference to the Headers, allowing the allocating to be reused (see the my_ip example changes). Connection::send_response now accepts the fields of the Response as arguments because Headers is owned in it, but accepting a &Response doesn't work because we do need ownership of the body.
Also clean up some of the lifetime naming in the body module.
For Headers::is_empty and Headers::{get,get_value} with the header not in the list.
This doesn't test everything yet, but it's a good start. Also cleans up the implementation in places.
Same ones from the main Heph crate.
Use a proper LICENSE file for the Heph-HTTP crate.
Implements fmt::Debug for all public types, ignores some return arguments that aren't useful.
So it can be used in the HTTP client as well.
These will also be used in the client module.
Various edge cases and some fmt::Display implementation tests.
Still has plenty of thing to do: * Fix number of TODO/todo!s. * Add tests.
This still needs work, but I'm merging as is. |
Follow up issue #464. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the initial version of the Heph-HTTP crate. This currently only implements a low level API with little extras, trying to go for lowest possible overhead.
Closes #54.
Closes #45.