cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Content Type - Message Boundary issue in YouTube upload

From: Tanmay Anjaria <tanmay.anjaria_at_gmail.com>
Date: Wed, 14 Jan 2009 08:21:55 +0530

Hi Daniel,

Thanks for the response.

>"I don't follow you. It uses that header when you're "uploading video
through youtube website" and "in my case too". Isn't that good then?"

No, it's not good enough. Because as I mentioned, I use
*multipart/related*and still it shows in pcap as Content-Disposition:
form-data; which is
incorrect.

I'm not using any HTML forms in my program.

*My doubt is:* In spite of setting multipart/related in the HTTP post, why
does the pcap show Content-Disposition: form-data;

I set it like this:

char boundary[MAX_PATH]="multipart/mixed; boundary=1a177433f849";

        curl_formadd( &formpost, &lastptr,
                              CURLFORM_COPYNAME, "Content-Type:",
                              CURLFORM_NAMELENGTH, strlen("Content-Type:"),
                              CURLFORM_COPYCONTENTS, boundary,
                              CURLFORM_CONTENTSLENGTH,strlen(boundary),
                              CURLFORM_END );

Is there any mistake in the way I'm setting it?

>"If the multipart formpost behavior isn't what you like/need/want, you'll
need to do it all yourself with the "normal" POST approach."

I think multipart/related will do in my case. I'm providing here the HTTP
posts that I'm making. This is suggested on YouTube developers' site.

POST /feeds/api/users/default/uploads HTTP/1.1
Host: uploads.gdata.youtube.com
Authorization: AuthSub token="<authentication_token>"
GData-Version: 2
X-GData-Client: <client_id>
X-GData-Key: key=<developer_key>
Slug: <video_filename>
*Content-Type: multipart/related;* boundary="<boundary_string>"
Content-Length: <content_length>
Connection: close

--<boundary_string>
Content-Type: application/atom+xml; charset=UTF-8

API_XML_request
--<boundary_string>
Content-Type: <video_content_type>
Content-Transfer-Encoding: binary

<Binary File Data>
--<boundary_string>--

Thanks,
Tanmay

On Tue, Jan 13, 2009 at 10:42 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Tue, 13 Jan 2009, Tanmay Anjaria wrote:
>
> I captured the network traffic while uploading video through youtube
>> website
>> and then captured the network traffic while running my program.
>>
>> In the captured pcap file while uploading video through web site, it shows
>>
>> *Content-Disposition: form-data;* for every header.
>>
>> and in my case too, it shows the same thing, which should not be the case.
>>
>
> I don't follow you. It uses that header when you're "uploading video
> through youtube website" and "in my case too". Isn't that good then?
>
> Anyway, libcurl does those headers since you're doing a multipart formpost.
>
> As I'm setting *- Content-Type: multipart/related; boundary="
>> <boundary_string>"*
>>
>
> Since libcurl does the boundary strings within the body, between the
> formparts, it also has to do it in the Content-Type: header and thus you
> cannot replace that header when doing multipart formposts. I wouldn't mind
> having such abilities, but there aren't any such right now.
>
> If the multipart formpost behavior isn't what you like/need/want, you'll
> need to do it all yourself with the "normal" POST approach.
>
> --
>
> / daniel.haxx.se
>
Received on 2009-01-14