user1692342
user1692342

Reputation: 5237

Calculating Content Length in multipart HTTP bodies

I am creating a HTTP POST message, and I have a dobut regarding the content length value.

Say my body is as shown below:

POST http://somelink HTTP/1.1
Date: Mon, 22 Feb 1857 12:27:07 GMT
Content-Length:  21797487
Content-Type: multipart/form-data; boundary=---------------------------boundary

-----------------------------boundary
Content-Type: text/plain
Content-Disposition: form-data; name="tid"

someid

-----------------------------boundary
Content-Type: image/jpeg
Content-Disposition: form-data; filename="image.jpeg"; name="File"

SomeRandomtext

-----------------------------boundary--

Should the content length include the \r\n after boundary-- or it should end at boundary--

Upvotes: 0

Views: 1435

Answers (1)

Julian Reschke
Julian Reschke

Reputation: 42027

From the protocol point of view, the payload type doesn't matter. The content length is the length of the message that follows the header block, that's it.

Upvotes: 4

Related Questions