cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: problem with HTTPS post of file: "Expectation failed"

From: Chris Dawson <xrdawson_at_gmail.com>
Date: Thu, 24 Nov 2005 13:25:10 -0800

I've noticed from the trace output that there is a header called "Expect:
100-continue" Does this sound like something that could be causing the
server to respond with "Expectation failed?" I don't see anything on the
curl man page to turn this on or off; can anyone explain what this is used
for?

And, is there a way to get more of the output of the multipart form post? I
see in the livehttpheaders dump that it builds something like this:

Content-Type: multipart/form-data;
boundary=---------------------------6243430617906378141649257231
Content-Length: 5731505
-----------------------------6243430617906378141649257231
Content-Disposition: form-data; name="episode[title]"

test
-----------------------------6243430617906378141649257231
Content-Disposition: form-data; name="episode[description]"

I cannot tell if curl is doing the same thing because it truncates the trace
output.

Thanks

On 11/23/05, Ralph Mitchell <ralphmitchell_at_gmail.com> wrote:
>
> The first section shows a post to https://podasp.com/user/login, with args
> as shown right under the Content-Length line. There's a cookie, so you'll
> want to send that too. The response is "302 Found" with a Location header,
> which is a redirect. All that translates to something like this:
>
> curl -b jar.txt -c jar.txt -s -S -L -o loginoutput.html \
> -d "user%5Blogin%5D=foo&user%5Bpassword%5D=foobar&commit=Login" \
> https://podasp.com/user/login
>
> The next thing of interest is GETting the episode list:
>
> curl -b jar.txt -c jar.txt -s -S -L -o episodelist.html \
> https://podasp.com/episode/list
>
> followed by getting the new episode list:
>
> curl -b jar.txt -c jar.txt -s -S -L -o episodenew.html \
> https://podasp.com/episode/new
>
> That gets you to the point where you'd be make the post you originally
> asked about, but I've never had occasion to do a multipart/form-data post,
> so I'll stop there... :) You might be able to skip the episode/list &
> episode/new GETs, as nothing exciting is happening with cookies there. On
> the other hand, the server may be associating things with your session to
> remember where you went, and if so it might not play nice if you don't
> follow the right sequence.
>
> Ralph Mitchell
>
>
> On 11/23/05, Chris Dawson <xrdawson_at_gmail.com> wrote:
> >
> > I captured the output but am still not sure how to read the output and
> > convert to a curl statement. Can someone help me with a little more
> > information?
> >
> > http://webcastinabox.com/projects/podasp/livehttp.txt
> >
> > Thanks, I am learning a lot!
> >
> > Chris
> >
> > On 11/23/05, Daniel Stenberg <daniel_at_haxx.se > wrote:
> > >
> > > On Tue, 22 Nov 2005, Chris Dawson wrote:
> > >
> > > > I am trying to make a post to an HTTPS server with curl. The server
> > > > requires me to login and store a session cookie which I can then use
> > > on
> > > > subsequent requests, and this works fine. I cannot make a file
> > > post,
> > > > however, and am unsure why. I used --trace trace.txt and this
> > > provides me
> > > > with a trace file that indicates the server has responded with
> > > "Expectation
> > > > failed." I don't really know what to make of this.
> > >
> > > You should use LiveHTTPHeaders and capture a session you do manually,
> > > and then
> > > compare that with the trace from curl. It should give you a pretty
> > > good idea
> > > of what the differences are.
> > >
> > > > More context: the form which I am posting to has several variables
> > > which I
> > > > think I need to post as well. So, the form looks like this:
> > > >
> > > > <form>
> > > > <input type="text" name="episode[title]">
> > > > <input type="text" name="episode[description]">
> > > > <input type="file" name="episode_mp3_file">
> > > > <submit>
> > > > </form>
> > > >
> > > > The command I am using for curl is this:
> > > > curl -b jar.txt -c jar.txt --trace trace.txt -k -F
> > > "episode_mp3_file=@
> > > > small.mp3" https://podasp.com/episode/create
> > >
> > > So your command line doesn't add two of the parts, which very well
> > > might be
> > > the reason for the server's message.
> > >
> > > > Does this indicate that I am not sending the form variables
> > > "episode[title]"
> > > > for example?
> > >
> > > I would assume so.
> > >
> > > > I think the server does require at least some of these variables in
> > > order to
> > > > process the request, but this error message seems to me to be before
> > > the
> > > > upload even begins, so I wonder how the server knows to do this.
> > >
> > > It could possibly be that the server requires the fields to come in a
> > > specific
> > > order and it checks them immediately on "arrival" and thus can reject
> > > the POST
> > > early. But this is pure speculations on my behalf.
> > >
> > > > I tried to post form variables alongside the file post (with -d
> > > > "episode[title]=Upload") but I got a complaint: "You can only
> > > select one
> > > > HTTP request!"
> > >
> > > You need to add those parts with -F as well. -d implies a "plain"
> > > POST, while
> > > -F builds a series of parts for a multipart formpost.
> > >
> > > --
> > > Commercial curl and libcurl Technical Support:
> > > http://haxx.se/curl.html
> > >
> >
> >
>
Received on 2005-11-24