electron: `uploadData` is missing on custom protocol's request when send via XHR

  • Output of node_modules/.bin/electron --version: v2.0.8
  • Operating System (Platform and Version): MacOS 10.13.6

Expected Behavior

Sent data via POST / PUT XMLHttpRequest to custom stream protocol handler should appear under uploadData property in of the request object.

Actual behavior

request.uploadData property is undefined when data is send via XMLHttpRequest, although it’s worth mentioning that it does appear as expected if data is send via fetch API.

I will try to create self contained reproducible test case, but posting this here in case it’s already a known issue or limitation.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (5 by maintainers)

Most upvoted comments

My patch landed in upstream: https://chromium-review.googlesource.com/c/chromium/src/+/3040243 so I’m going to close this out. Should be fixed the next time we roll Chromium, and will go out in Electron 15. Wouldn’t be too hard to backport if we need to.

It turns out this is hard-coded in blink.

  1. blink checks AreMethodAndURLValidForSend in send: ref
  2. AreMethodAndURLValidForSend checks KURL::ProtocolIsInHTTPFamily: ref
  3. KURL::ProtocolIsInHTTPFamily will only return true if the protocol is http or https: ref

I did a little research and it has been this way since blink was WebKit was KHTML: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/xmlhttprequest/xml_http_request.cc;l=243;drc=7ea4ebf0bee3d58001fa2b7f7774262701f8e6be

I’m not sure if it is worth us floating a patch here, but I’ve thrown something up upstream. Let’s see what Chromium has to say: https://chromium-review.googlesource.com/c/chromium/src/+/3040243

@MarshallOfSound or @codebytere ; would someone please re-open this issue. It still persists in Electron 11.3.0. I have tested this with axios and direct XMLHttpRequest instances.

For anyone who needs some form of custom protocol communication with POST, PUT, or other methods that need a body. The standard fetch API still works just fine.

If you use axios, this adapter will allow it to work with fetch: https://github.com/axios/axios/pull/2891/checks

@Gozala Can you open this issue (because problem still exists) ?

I can’t only members of the repo can, which I am not.

@codebytere can you open this issue?

@sofianguy I am still experiencing this bug on Electron 9.1.0. Can you please reopen this bug?

Platform: Manjaro Linux 64-bit