File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -232,10 +232,17 @@ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
232232 [request setValue: requestHeaders[header] forHTTPHeaderField: header];
233233 }
234234
235+ // Set body data (Typed Array or String)
235236 if ( argc > 0 ) {
236- NSString *requestBody = JSValueToNSString ( ctx, argv[0 ] );
237- NSData *requestData = [NSData dataWithBytes: [requestBody UTF8String ] length: [requestBody length ]];
238- [request setHTTPBody: requestData];
237+ if ( JSTypedArrayGetType (ctx, argv[0 ]) != kJSTypedArrayTypeNone ) {
238+ size_t length = 0 ;
239+ void *data = JSTypedArrayGetDataPtr (ctx, argv[0 ], &length);
240+ request.HTTPBody = [NSData dataWithBytes: data length: length];
241+ }
242+ else {
243+ NSString *requestBody = JSValueToNSString ( ctx, argv[0 ] );
244+ request.HTTPBody = [requestBody dataUsingEncoding: NSUTF8StringEncoding];
245+ }
239246 }
240247
241248 if ( timeout ) {
You can’t perform that action at this time.
0 commit comments