Problem formatting HTTP multipart request with chunked transfer-encoding

Hello,

I'm trying to do an HTTP multipart POST with chunked transfer encoding but am having trouble sending the headers to the socket. When trying to send, I receive a -1. I used strerror(errno) and found that I was getting "err: 5, I/O error" every time I tried to send the headers to the socket. I was unable to find any more details on this online, so I was wondering if anyone could explain potential causes to this error. 

Additionally, I have some confusion regarding the format of the request. For multipart POST with chunked transfer encoding, is it something like this? 

POST /upload HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Transfer-Encoding: chunked

3B\r\n
------WebKitFormBoundary7MA4YWxkTrZu0gW\r\n
Content-Disposition: form-data; name="text_field"\r\n\r\n
Example Text\r\n
1E\r\n
------WebKitFormBoundary7MA4YWxkTrZu0gW\r\n
Content-Disposition: form-data; name="file_field"; filename="example.jpg"\r\n
Content-Type: image/jpeg\r\n\r\n
\r\n
<chunked binary data of example.jpg>\r\n
5\r\n
\r\n
0\r\n
\r\n
------WebKitFormBoundary7MA4YWxkTrZu0gW--\r\n

Parents Reply
  • It's hard to give a clear answer based on error code only, but EIO (at the time of NCS 2.5.2) was widely used in TLS sockets, would be good to clarify whether it's really HTTP, or rather HTTPS. The latter could indicate some issues with mbed TLS configuration.

    As for the chunked request format you provide, it seems a bit suspicious too. You seem to mix up headers with chunked payload, also the chunk sizes do not seem to match the actual payload size.

Children
No Data
Related