RE: Content-Length in multipart/related

> -----Original Message-----
> From: www-talk-request@w3.org [mailto:www-talk-request@w3.org]On Behalf
> Of Luca Di Luzio
> Sent: Friday, January 12, 2001 4:48 AM
> To: fish@infidels.org
> Cc: www-talk@w3.org
> Subject: Content-Length in multipart/related
>
>
> Hi Fish (and all W3C mailing list),

Hi. :)

> I saw in the W3C mailing list your comment on the content-length in
> multipart/mixed.
> I think you are very expert of this argument and then I'd like to ask you
> how to calculate the value of the content-length in a multipart/related
> type.
> I have to send to a Wap Gateway an HTTP message where the content is a
> multipart/related type; so this message must contain the content-length
> header.
>
> This is and example:
>
> POST /cgi-bin/wap_push.cgi HTTP/1.1
> Host: www.wireless-network.com
> Date: Sun, 16 May 1999 18:13:23 GMT
> Content-Type: multipart/related; boundary=asdlfkjiurwghasf;
> type="application/xml"
> Content-Length: (???????????)
>
> --asdlfkjiurwghasf
> Content-Type: application/xml
> <?xml version="1.0"?>
> <!DOCTYPE pap PUBLIC "-//WAPFORUM//DTD PAP 1.0//EN"
> "http://www.wapforum.org/DTD/pap_1.0.dtd">
> <pap>
> ..control..
> </pap>
>
> --asdlfkjiurwghasf
> Content-Type: text/vnd.wap.wml
> <?xml version="1.0"?>
> <!DOCTYPE WML PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
> "http://www.wapforum.org/DTD/wml_1.1.xml">
> <wml>
> <card>
> <p>Hello world!</p>
> </card>
> </wml>
> --asdlfkjiurwghasf--
>
> The rows of the boundary (called "--asdlfkjiurwghasf") are included in the
> content-length value?

Yes.

> And the rows called "Content-Type: application/xml" and
> "Content-Type: text/vnd.wap.wml"?

Yes.

> Thanks in advance. (and sorry for my bad English)
> Luca from Italy

The content of an HTTP message can be anything you want. Anything. But the
Content-Length header MUST specify the exact length of that content. In your
case the content is actually a multipart message surrounded by certain boundary
strings, but HTTP doesn't know or care.

Consider the following [rather unrealistic but nonetheless illustrative]
analogy: You want to send each of your three friends (who live in another city)
a box of chocolate. Each box weighs 2 kilograms.

Your address each box to the appropriate person, and then to be sure none of
them melt before they get there, you put all three of them inside a small
refrigerator (with lots of ice). The refrigerator itself weighs 25 kilograms.

You then contact the "HTTP Trucking Company" about shipping your package. The
trucking company naturally asks: "What are you shipping, and how much does it
weigh?"

What's the correct answer?

   a. Three boxes of chocolate, total weight: 6 kilograms.
   b. One refrigerator, total weight (including contents): 31 kilograms.

I hope you'll see that the correct answer is b. :)

Thus, the answer to your original question is: the Content-Length would be the
length of ALL data following the HTTP headers, which includes the boundary
strings and MIME headers too (which is just 'data' as far as HTTP is concerned).

--
"Fish" (David B. Trout)
   fish@infidels.org

Received on Sunday, 14 January 2001 19:20:25 UTC