cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: How to POST by curl command line tool as follws...

From: Alessandro Vesely <vesely_at_tana.it>
Date: Thu, 18 Oct 2007 08:58:13 +0200

劍豪 wrote:
> Dear sir:
>
> I found what IE post by httplook as follws...
> And my question is how to POST by curl command line tool as follws?
> I write my answer at last, is it right?

Yes and no...

> ------------------------------------------------------------------------
> POST http://demi.zhao.blog.163.com/blog/static/38118965200791333615774/dwr/exec/BlogBean.addComment.dwr HTTP/1.0
> Accept: */*
> Content-Type: text/plain

Your POST is unusual because it sends a text/plain file.
There is nothing in the HTTP protocol that mandates the use of the
HTML standard content types. However, curl assumes them by default.
Use, e.g., -H "Content-Type: text/plain" to specify the content type.

> Referer: http://demi.zhao.blog.163.com/blog/static/38118965200791333615774/

Ok, the server script may or may not verify this header

> Proxy-Connection: Keep-Alive
> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

The server script may or may not verify this header

> Host: demi.zhao.blog.163.com
> Content-Length: 1048
> Pragma: no-cache
> Cookie: NTESBLOGSI=83E2A214547975F3AB35F39C85B67BB3.app-27

The server script probably requires this header. Probably it is not enough
to use a fixed value: you may need a separate curl invocation to get the
cookie. See curl options -b and -c.

>
> callCount=1
> [...]
> c0-e1=string:_fks_Rewn0KT0OncJrP8BRLNl9485efthha7q
> xml=true

Since that is not produced by a standard HTML form, there are probably
some client scripts for doing it. You may need some understanding of them
in order to grasp the meaning of the content and any relations it may have
with the cookie.
> ------------------------------------------------------------------------
>
> I write all text line break by line break to the file "C:\all.txt"
> and my command line is like this:
>
> curl [...] -d "@C:\all.txt" [...]

Option -d does not send end of lines. You need --data-binary to send them.
Received on 2007-10-18