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

HTTPRequest: Expose and add methods to make working with headers easier #63713

Conversation

Kubulambula
Copy link
Contributor

@Kubulambula Kubulambula commented Jul 31, 2022

Closes 4734

Exposes has_header() and get_header_value() methods and adds get_dictionary_from_headers method.

Also converts headers to lower-case in HTTPClient::_get_response_headers_as_dictionary() as well as in HTTPRequest::get_dictionary_from_headers() to keep consistensy.

This should be a done right version of 62962

@timothyqiu
Copy link
Member

Since the headers are returned as a dictionary, I think it'll be easier to work with if the keys are always lower-cased.

Users can then use lower-cased names to get the header value. Otherwise, they have to iterate through the keys and make case-insensitive compares.

@Kubulambula
Copy link
Contributor Author

Since the headers are returned as a dictionary, I think it'll be easier to work with if the keys are always lower-cased.

Users can then use lower-cased names to get the header value. Otherwise, they have to iterate through the keys and make case-insensitive compares.

I have done it this way in order to keep consistency with HTTPClient.
It would make sense to make the keys case-insensitive in my opinion, but do it the same way in both cases

@Kubulambula
Copy link
Contributor Author

Should be all good now

@mhilbrunner
Copy link
Member

The commits need to be squashed into 1 commit :)

…sier

Exposes `has_header()` and `get_header_value()` methods and adds `get_dictionary_from_headers` method.

Add documentation

Update doc/classes/HTTPRequest.xml

Make HTTPClient.get_response_headers_as_dictionary()  and HTTPRequest.get_dictionary_from_headers() use lower-case keys

Fix typo

Co-Authored-By: Max Hilbrunner <[email protected]>
@Kubulambula Kubulambula force-pushed the HTTPRequest-header-utility-function branch from 6ba8c17 to 2c1c706 Compare August 5, 2022 14:38
@YuriSizov YuriSizov modified the milestones: 4.0, 4.1 Feb 10, 2023
@YuriSizov YuriSizov requested review from a team and removed request for a team February 10, 2023 14:42
@YuriSizov YuriSizov modified the milestones: 4.1, 4.2 Jun 14, 2023
@AThousandShips AThousandShips modified the milestones: 4.2, 4.3 Oct 26, 2023
@AThousandShips AThousandShips modified the milestones: 4.3, 4.4 Jul 25, 2024
@pafuent
Copy link
Contributor

pafuent commented Sep 18, 2024

@Kubulambula if it's OK with you, I can create a new PR with this changes and add you as co-author.

@Kubulambula
Copy link
Contributor Author

@Kubulambula if it's OK with you, I can create a new PR with this changes and add you as co-author.

No problem at all. I would be happy if this functionality makes it in!

@akien-mga
Copy link
Member

Superseded by #97174. Thanks for the contribution!

@akien-mga akien-mga closed this Sep 19, 2024
@akien-mga akien-mga removed this from the 4.4 milestone Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make working with headers trough HTTPRequest easier
7 participants