-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Implement header line folding (fixes #37, #68) #107
Conversation
73bfcd9
to
dd936b8
Compare
assert_eq!(response.reason.unwrap(), "OK"); | ||
assert_eq!(response.headers.len(), 1); | ||
assert_eq!(response.headers[0].name, "Line-Folded-Header"); | ||
assert_eq!(response.headers[0].value, &b"hello \r\n \r\n there"[..]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, this was what I was wondering: how exactly does it get exposed. Am I right in assuming that this implies it will "simply" capture the text from the first line until the end of all obs-folded lines? So, if this were hello: there\r\n mister\r\n baguette\r\n
, it would scoop it all as b"there\r\n mister\r\n baguette"
?
That seems elegant. Just to consider what I'd thought of, I assumed this feature would instead use up an entry in the &mut [Header]
slice for each line. If the line started with obs-folding, then the parse would just grab the name from the previous entry. So it'd look something like this:
assert_eq!(resp.headers[0].name, "hello");
assert_eq!(resp.headers[0].value, &b"there");
assert_eq!(resp.headers[1].name, "hello");
assert_eq!(resp.headers[1].value, &b"mister");
assert_eq!(resp.headers[2].name, "hello");
assert_eq!(resp.headers[2].value, &b"baguette");
Whatever we end up using, explaining that is what it does would be useful as a sentence/paragraph in the commit description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line folds are equivalent to spaces, but multiple entries of a single header are equivalent to a single entry combined with commas, so we can't return multiple entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right.... gross...
Welp, then I think this is the best we can do. I think it'd be good to better explain, perhaps with an example, in the documentation for that builder method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an example to the builder method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
No description provided.