curl-users
Re: problem with HTTPS post of file: "Expectation failed"
Date: Wed, 23 Nov 2005 09:35:02 +0100 (CET)
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.htmlReceived on 2005-11-23