godot icon indicating copy to clipboard operation
godot copied to clipboard

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

Open Kubulambula opened this issue 3 years ago • 4 comments

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

Kubulambula avatar Jul 31 '22 09:07 Kubulambula

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.

timothyqiu avatar Aug 01 '22 01:08 timothyqiu

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 avatar Aug 02 '22 15:08 Kubulambula

Should be all good now

Kubulambula avatar Aug 05 '22 10:08 Kubulambula

The commits need to be squashed into 1 commit :)

mhilbrunner avatar Aug 05 '22 13:08 mhilbrunner