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

Connection doesn't offer any way to iterate its contents #106

Open
lilyball opened this issue Mar 17, 2022 · 1 comment
Open

Connection doesn't offer any way to iterate its contents #106

lilyball opened this issue Mar 17, 2022 · 1 comment

Comments

@lilyball
Copy link

The Connection header lets me test if it contains specific "connection options"1 are contained in it. But it doesn't let me actually iterate its contents to see what it contains.

This is very frustrating as I need to actually know what's in the header because I'm implementing a gateway and I need to strip the referenced header names from the request I'm proxying. I would really like to be able to use headers::Connection so I don't have to worry about parsing the comma-separated list myself.

In theory I could just parse the header and then walk the whole headers map and compare each entry to the Connection, except HeaderMap does not offer a retain() operation and so that approach would require reallocating the whole map even if I don't end up making any changes.

Footnotes

  1. This is represented as a private impl AsConnectionOption type, which means it's undocumented. Really that should be changed so AsConnectionOption is public and simply inherits from a sealed trait, so the generated docs will at least tell me what implements it. Or maybe change it to use impl AsRef<str> instead, or even impl AsRef<[u8]> as that supports the required comparison too.

@seanmonstar
Copy link
Member

We could come up with an fn iter(&self) -> impl Iterator (what would the items be? &str?). Would you like to propose that and send a PR?

which means it's undocumented. Really that should be changed

But it's not undocumented, the documentation for the contains method lists exactly what types can be passed. So, I don't think it will be changed.

This is very frustrating

Is it frustrating? If so, I'm sorry about that. However, a missing function shouldn't typically be frustrating. It's just something that would be nice to add. I'd recommend trying to frame feature requests in a positive way.

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

No branches or pull requests

2 participants