reflex-dom icon indicating copy to clipboard operation
reflex-dom copied to clipboard

Missing HTTP headers get reported as the empty string

Open enobayram opened this issue 2 years ago • 0 comments

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: https://github.com/reflex-frp/reflex-dom/blob/2028ff64becdfc28032b7e6a91fcdbc285d39d2f/reflex-dom-core/src/Reflex/Dom/Xhr/Foreign.hs#L87

enobayram avatar Jan 11 '23 19:01 enobayram