@@ -318,6 +318,10 @@ class HTTPWasmClient : public HTTPClient {
318318 i++;
319319 }
320320
321+ const int buffer_length = info.buffer_in_len ;
322+ char *payload = (char *)malloc (buffer_length);
323+ memcpy (payload, info.buffer_in , buffer_length);
324+
321325 // clang-format off
322326 char *exe = NULL ;
323327 exe = (char *)EM_ASM_PTR (
@@ -355,10 +359,15 @@ class HTTPWasmClient : public HTTPClient {
355359 i += 2 ;
356360 }
357361
358- xhr.setRequestHeader (" Content-Type" , " application/octet-stream" );
362+ // xhr.setRequestHeader("Content-Type", "application/octet-stream");
363+ // xhr.setRequestHeader("Content-Type", "text/json");
359364 try {
360- xhr.send (new Uint8Array (0 ));
361- // xhr.send(UTF8ToString($4));
365+ var post_payload = new Uint8Array ($5 );
366+
367+ for (var iii = 0 ; iii < $5 ; iii++) {
368+ post_payload[iii] = Module.HEAPU8 [iii + $4 ];
369+ }
370+ xhr.send (post_payload);
362371 } catch {
363372 return 0 ;
364373 }
@@ -389,9 +398,11 @@ xhr.setRequestHeader("Content-Type", "application/octet-stream");
389398 Module.HEAPU8 .set (LEN123, fileOnWasmHeap);
390399 return fileOnWasmHeap;
391400 },
392- path.c_str (), n, z, " POST" , info. buffer_in );
401+ path.c_str (), n, z, " POST" , payload, buffer_length );
393402 // clang-format on
394403
404+ free (payload);
405+
395406 i = 0 ;
396407 for (auto h : info.headers ) {
397408 free (z[i]);
0 commit comments