cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: cURL on Windows Xp: "Content-Length Header required" error

From: Tanmay Anjaria <tanmay.anjaria_at_gmail.com>
Date: Mon, 12 Jan 2009 14:46:18 +0530

Hey All,

As I mentioned earlier, I am working on YouTube Uploading project in WinXp
using cURL and google data APIs.

I was *able to pass the authentication stage* and thanks for all the inputs
from u ppl :)

YouTube gives a long authentication string for further Uploading task which
is to be used by the developer.

*I need to post a number of things before the actual binary data
file.*Please see the list as below:

It's from the link:
http://code.google.com/apis/youtube/2.0/developers_guide_protocol_direct_uploading.html#Direct_uploading

=====================

POST /feeds/api/users/default/uploads HTTP/1.1
Host: uploads.gdata.youtube.com
Authorization: AuthSub token="DXAA...sdb8"
GData-Version: 2
X-GData-Client: b1c4t9sl2159
X-GData-Key: key=adf15ee97731bca89da876c...a8dc
Slug: video-test.mp4
Content-Type: multipart/related; boundary="f93dcbA3"
Content-Length: 1941255
Connection: close

--f93dcbA3
Content-Type: application/atom+xml; charset=UTF-8

<?xml version="1.0"?>
<entry <http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_entry>
xmlns="http://www.w3.org/2005/Atom"
  xmlns:media="http://search.yahoo.com/mrss/"
  xmlns:yt="http://gdata.youtube.com/schemas/2007">
  <media:group <http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:group>>
    <media:title
<http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:title>
type="plain">Bad Wedding Toast</media:title>
    <media:description
<http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:description>
type="plain">
      I gave a bad toast at my friend's wedding.
    </media:description>
    <media:category
<http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:category>
      scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People
    </media:category>
    <media:keywords
<http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:keywords>>toast,
wedding</media:keywords>
  </media:group>
</entry>
--f93dcbA3
Content-Type: video/mp4
Content-Transfer-Encoding: binary

<Binary File Data>
--f93dcbA3--

=====================

Now, my question is *how to send all these using HTTP POST*? I'm looking
into CURLOPT_HTTPPOST, but through that u can only send one post at a time
and that too only of an HTTP header.

Is there anyway I can bundle all of these and then send in one time shot?

Any suggestions for making these HTTP POST will be welcome...

Thanks & Regards,
Tanmay Anjaria

On Sat, Jan 10, 2009 at 5:09 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Sat, 10 Jan 2009, Tanmay Anjaria wrote:
>
> Below mentioned are the 3 command line args that I wanted to send to
>> YouTube:
>>
>> curl \
>> --location https://www.google.com/youtube/accounts/ClientLogin \
>> --data 'Email=testuser&Passwd=testpw&service=youtube&source=Test' \
>> --header 'Content-Type:application/x-www-form-urlencoded'
>>
>
> Use curl's --libcurl option to get a rough C version of the same thing.
> --header is not needed as it sets the same header libcurl will use anyway.
>
> CURLOPT_URL, CURLOPT_FOLLOWLOCATION and CURLOPT_POSTFIELDS seems to be
> about the only options you need.
>
> Oh, and perhaps CURLOPT_WRITEFUNCTION etc to get the response back in some
> way you like.
>
> --
> Daniel
>
Received on 2009-01-12