Henrik Frystyk Nielsen [frystyk@w3.org] wrote:
> - The command line tool can do HTTP/1.1 PUT, POST, DELETE, OPTIONS,
and
> TRACE. It can handle special situations like redirections on a PUT,
etc.
> More information is available at
Ehrm. I've seen a lot of questions in this list relating to the use of
the POST
command in the command line tool. Users claimed again and again it
doesn't
work. Why?
The answer is simple: POST isn't implemented in the command line tool.
Just open up the tools source file HTLine.c and scroll down to line 495:
case METHOD_POST:
if (formdata) {
HTParentAnchor * posted = NULL;
posted = HTPostFormAnchor(formfields, (HTAnchor *) cl ->
anchor,
cl -> request );
status = posted ? YES : NO;
} else {
/* MORE */
status = NO;
}
break;
As you can clearly see, the post method is not properly implemented.
Any tries to use it will result in error messages. HOWEVER, there is
still
a way to use POST, which is obvious if you look at the above code
snippet: the method will be properly called if you provide it with data,
not via file as in the documentation, but via the bogus undocumented
formdata command line option. (You can probably find out it's workings
by examining the source code...)
Thus: POSTing a single CGI environment variable can be done this way:
w3c -form -post http://myserver/mydir/mycgiscript MYCGIVARIABLE=123XYZ
POSTing multiple variables is NOT possible. The bogus formdata option
accepts one variable only. For example I use the following syntax in a
cron job to post data to a remote database using http and POST:
w3c -form -post http://... RECORD=ID#COL1#COL2#COL3#COL4#COL4
Note the use of hash signs (#) as separators. The bogus formdata option
will interpret a comma (,) as field separator or something so it just
won't
work. Use the # instead.
This is not very neat however...
MVH
TB/DH Linus Walleij 046 193678 <linus.walleij@ex1.ecs.ericsson.se>