Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for setting responseType to array buffer #148

Merged
merged 1 commit into from
Mar 10, 2016
Merged

added support for setting responseType to array buffer #148

merged 1 commit into from
Mar 10, 2016

Conversation

TimvdEijnden
Copy link
Contributor

I was having trouble loading binary files when using Mirage in my Ember project. It seems that pretender didn't support other responses than text.

This change allow you to set the contentType of an XHR request to arraybuffer, this results in the binary content being available using the response property.

var xhr = new XMLHttpRequest();
  xhr.open("GET", '/assets/pretender.ogg', true );
  // important because this allow to load the binary data correctly, it makes the response available which contains the arraybuffer
  xhr.responseType = 'arraybuffer';
  xhr.onload = function ()
  {
   var arrayBuffer = xhr.response;
  };
  xhr.send();

this PR fixes #72

@TimvdEijnden
Copy link
Contributor Author

@trek Please review my PR, would be awesome if it's added! 🎵

@deepan83
Copy link

deepan83 commented Mar 1, 2016

We need this for our apps as well...so would be great if it is added!

@TimvdEijnden
Copy link
Contributor Author

I'm required to use my own branch in my project now. There isn't much activity lately. 😿

@simonihmig
Copy link
Contributor

Also using my own fork (#79), +1 for getting this merged!

trek added a commit that referenced this pull request Mar 10, 2016
added support for setting responseType to array buffer
@trek trek merged commit 318acfc into pretenderjs:master Mar 10, 2016
@trek
Copy link
Member

trek commented Mar 10, 2016

Thanks! This will be in next release (coming shortly)

@TimvdEijnden TimvdEijnden deleted the add_responseType_support branch April 21, 2016 09:02
@bhaidar
Copy link

bhaidar commented Feb 4, 2020

Hi @TimvdEijnden can you share how you used the responseType: arraybuffer to return binary data? thanks

@TimvdEijnden
Copy link
Contributor Author

@bhaidar We used it to load sound files as in the example in the start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binary files are converted to strings
5 participants