2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Allow ArrayBuffer and related views as data

In order to push binary data under the form of ArrayBuffer and
its related views (Int8Array, ...) one needs not to stringify
those.

For the XHR adapter there is nothing to do as it natively supports
ArrayBuffer in req.send().

Node's http adapter supports only string or Buffer thus a
transformation to Buffer is required before setting content length
header.
This commit is contained in:
Mathieu Bruyen
2014-09-18 09:07:08 +02:00
parent d8f687dc52
commit 095a204c5b
8 changed files with 124 additions and 9 deletions
+2
View File
@@ -150,6 +150,7 @@ This is the available config options for making requests. Only the `url` is requ
// `transformRequest` allows changes to the request data before it is sent to the server
// This is only applicable for request methods 'PUT', 'POST', and 'PATCH'
// The last function in the array must return a string or an ArrayBuffer
transformRequest: [function (data) {
// Do whatever you want to transform the data
@@ -174,6 +175,7 @@ This is the available config options for making requests. Only the `url` is requ
// `data` is the data to be sent as the request body
// Only applicable for request methods 'PUT', 'POST', and 'PATCH'
// When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash
data: {
firstName: 'Fred'
},