Closed
Conversation
139f0e0 to
c0e8f44
Compare
cf9f79b to
743b33b
Compare
Renames Header.undecoded to Header.value. Add notes about concurrency usage of Header.decode.
743b33b to
349afd9
Compare
Contributor
Author
|
Closing this in support of discussion happening at #969 |
This file contains hidden or 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
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 PR adds typed Header API to cohttp-eio.
This is the first PR in this series. I will open additional PRs that will build on this PR and which will use the header api defined here. Future PRs will address changes required in Request, Response, (Server?) and Client modules. This is mostly to ease review and merge.
Usages of the new API can be seen in the header.md tests.
A Brief Overview
The header functionality implemented in the module
Headeraims to address the following core requirements,For (1) and (2) we define an extensible GADT -
where
'adefines the header type. For example to defineContent-Typeheader we define it asThis ensures that valid Content-Type header is an
int.The current PR provides implementation for three common HTTP headers,
Content-TypeandTransfer-Encodingand a type-unsafe, generic/catch all header aptly namedH name. The plan is to increase this number in future PRs after this PR is merged.Some headers are only applicable to either requests only or response only, as such they will be defined in Request and Response module respectively. Common headers to both Request and Response will be defined in the Header module itself.
Type
'a header = ..is also an extensible type so that end-users can define custom headers should they so desire, for example we can defineHeader1andHeader2as such:Tests in header.md contains a test for custom headers and its usage.
Lastly, the header values are not decoded during insertion time, they are encoded as a
'a Lazy.tvalues and are only decoded on demand. This ensures that we don't incur performance penalty for those headers which we may never use. The backing store of headers is a list so insertion is 0(1)./cc @avsm @mseri