Skip to content
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

Merged
merged 2 commits into from
Jan 28, 2022

Conversation

nox
Copy link
Contributor

@nox nox commented Jan 13, 2022

No description provided.

@nox nox force-pushed the line-folding branch 3 times, most recently from 73bfcd9 to dd936b8 Compare January 14, 2022 10:32
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"[..]);
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@seanmonstar seanmonstar merged commit 6915b23 into seanmonstar:master Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants