Skip to content

Trying to send a Blob with XHR2 sends the request with an empty body on Android 4+ #34

@ghinda

Description

@ghinda

Summary:

XMLHttpRequest 2 and Blob constructing are both supported in ICS and newer. Therefore we should be able to send a raw Blob as an ajax request's body using xmlhttprequest.send(blob).

Unfortunately, trying to send a Blob this way sends the request with an empty body/payload.

The Blob is constructed correctly, the issue is with the actual request.

The work-around is to create an ArrayBuffer, and send it in the same way, using xmlhttprequest.send(arraybuffer).

Here is a test using GitHub's API (used it for CORS support):
http://jsfiddle.net/ghinda/fRgbf/

Both sending methods (sending the blob and sending the arraybuffer) work on modern desktop browsers, while on Android only the "Send as ArrayBuffer" works. This is because, as said above, the request is sent empty, without an actual body/payload.

More details:
http://ghinda.net/jpeg-blob-ajax-android/

Platforms:

  • Android 4.0.x - 4.1.x

How to reproduce:

  1. Check the example on Android 4.0.x - 4.1.x

Reduced Example:

http://jsfiddle.net/ghinda/fRgbf/

Bug Tracker ticket(s):

Workarounds:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions