When the _xhrRequestConfig_responseHeaders of an XhrRequest gets configured as OnlyHeaders $ singleton "SomeHeader", the _xhrResponse_headers map of the resulting XhrResponse contains a value of "" for the SomeHeader header, even if the actual HTTP response doesn't contain any SomeHeader header.
I think this behavior is very surprising; It's unintuitive and it's inconsistent with configuring the XhrRequest as _xhrRequestConfig_responseHeaders = AllHeaders, which will (necessarily) return an XhrResponse with a _xhrResponse_headers map without a SomeHeader value.
I believe this fromMaybe "" is responsible for that behavior, and I don't understand what purpose it really serves by conflating the missing header vs. header with empty string cases:
|
xmlHttpRequestGetResponseHeader self header = fromMaybe "" <$> getResponseHeader self header |
When the
_xhrRequestConfig_responseHeadersof anXhrRequestgets configured asOnlyHeaders $ singleton "SomeHeader", the_xhrResponse_headersmap of the resultingXhrResponsecontains a value of""for theSomeHeaderheader, even if the actual HTTP response doesn't contain anySomeHeaderheader.I think this behavior is very surprising; It's unintuitive and it's inconsistent with configuring the
XhrRequestas_xhrRequestConfig_responseHeaders = AllHeaders, which will (necessarily) return anXhrResponsewith a_xhrResponse_headersmap without aSomeHeadervalue.I believe this
fromMaybe ""is responsible for that behavior, and I don't understand what purpose it really serves by conflating the missing header vs. header with empty string cases:reflex-dom/reflex-dom-core/src/Reflex/Dom/Xhr/Foreign.hs
Line 87 in 2028ff6