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

fix: don't expose hyper HeaderMap #2

Merged
merged 2 commits into from
Jun 3, 2024

Conversation

fontanierh
Copy link

We want our ResponseWrapper to not expose any of the hyper types.
This commit changes the return value of headers to return a HashMap<&str, &str> instead of a hyper::HeaderMap

@fontanierh fontanierh requested a review from spolu June 3, 2024 08:40
let key = key.as_str();
let value = match value.to_str() {
Ok(value) => value,
Err(err) => return Err(Error::InvalidParameter(Box::new(err))),
Copy link

Choose a reason for hiding this comment

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

This error is still hyper specific no?

Maybe get(&str) -> Result to make this more straightforward?

Copy link
Author

Choose a reason for hiding this comment

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

👍

Copy link
Author

Choose a reason for hiding this comment

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

This error is still hyper specific no?

It's eventsource specific

Copy link
Author

Choose a reason for hiding this comment

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

it's not a hyper error

Copy link
Author

Choose a reason for hiding this comment

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

Maybe get(&str) -> Result to make this more straightforward?

Makes the thing kind of painful to use IMHO

Copy link

@spolu spolu left a comment

Choose a reason for hiding this comment

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

LGTM if the error is not hyper specific 👍

@fontanierh
Copy link
Author

@spolu Still I think it's not ideal because this error is meant for invalid request params. I'm going to add an InvalidResponseHeader error.

@fontanierh fontanierh merged commit df8e425 into main Jun 3, 2024
@@ -58,6 +70,8 @@ pub enum Error {
MalformedLocationHeader(Box<dyn std::error::Error + Send + Sync + 'static>),
/// Reached maximum redirect limit after encountering Location headers.
MaxRedirectLimitReached(u32),
// Invalid response header.
InvalidResponseHeader(Box<dyn std::error::Error + Send + Sync + 'static>),
Copy link

Choose a reason for hiding this comment

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

Not sure it will fly with them as this list is meant for the main loop no ?

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