简体   繁体   中英

Sending multipart/related request via javascript and XmlHttpRequest

I'm trying to send multipart/related request to my own server based on cpprestsdk:

POST /test HTTP/1.1
Content-Type: multipart/related; boundary=-
---
Content-Type: application/json

{
   "testField": "testValue"
}
---
Content-Type: image/jpeg
Content-Length: 131745
Content-Transfer-Encoding: binary

[DATA (131745 bytes)]
---

The second part of request contains jpeg image in binary format and server successfully reads it and creates an image from that bytes. But then a see that request in Wireshark, it show about 192000 bytes of the image data, not 131745 as I expect. I assume that all of the request data converted to utf-8 by javascript's XmlHttpRequest because charset for multipart/related was not specified. Is there any way to avoid such overhead and send only original bytes?

问题是我将请求传递send XmlHttpRequestsend方法作为字符串值,而不是作为ArrayBuffer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM