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 Children
No Data
Related