chromiumembedded/cef

Support blob data with CefRequest PostDataElement

Opened this issue · 2 comments

Describe the bug
When sending a XHR/fetch request using a Blob, PostDataElement ends up with PDE_TYPE_EMPTY, but the post data isn't actually empty. Blobs have a DataElement type of network::DataElementDataPipe with tag type network::DataElement::Tag::kDataPipe but that apparently isn't being checked here https://github.com/chromiumembedded/cef/blob/6778/libcef/common/request_impl.cc#L1154-L1161 and the unhandled type winds up as PDE_TYPE_EMPTY. There are in fact two tag types, kDataPipe and kChunkedDataPipe that are unhandled.

Supporting DataPipe should be fairly straightforward and this arguably could be a feature request, but returning PDE_TYPE_EMPTY for unhandled tag types just seems wrong which is why I reported this as a bug. A new type such as PDE_TYPE_DATA_PIPE should be returned instead with the data probably just read into a byte array so it overall acts like PDE_TYPE_BYTES.

Supporting ChunkedDataPipe is more problematic however because it can be flagged as being readable only once. I suggest giving it a separate type such as PDE_TYPE_CHUNKED_DATA_PIPE_UNSUPPORTED and just not supporting it. This way it is at least distinct from PDE_TYPE_EMPTY to avoid any confusion and it can be documented as unsupported much easier.
 
To Reproduce
Steps to reproduce the behavior:

  1. Send an XHR or fetch request using a Blob.
  2. Observe DevTools's Network tab shows the request has post body.
  3. Inspect the CefRequest PostData via any one of the handler methods that are passed a CefRequest and observe PDE_TYPE_EMPTY.

Expected behavior
CefRequest PostData's first PostDataElement should have a type other than PDE_TYPE_EMPTY and the payload should be retrievable.

Screenshots
N/A

Versions (please complete the following information):

  • OS: ALL
  • CEF Version: 131.2.7, ALL

Additional context
Does the problem reproduce with the cefclient or cefsimple sample application at the same version?
Yes

Does the problem reproduce with Google Chrome at the same version?
No

Same use case as getting the post data at all really. Blob is unfortunately used by some devs and libs for everything, even for json or simple form encoded data, presumably because it keeps their interfaces cleaner when dealing with different types of data.