cURL / Mailing Lists / curl-users / Single Mail

curl-users

RE: https/post help

From: Jared Ingersoll <jared_at_cswv.com>
Date: Thu, 31 Jul 2003 07:45:20 -0400

Thanks for the help.

Strange, when I use the following script to do a POST:

#!/bin/sh
LD_LIBRARY_PATH=//usr/local/ssl/lib:/usr/local/lib
export LD_LIBRARY_PATH

#dataencode=`/usr/local/bin/perl -MURI::Escape -le 'print
uri_escape("$postdata")'`
data=`cat $1` # text file of encoded xml data

/usr/local/bin/curl -H "Host: betatest.cswcasa.com" -H "Authorization:
Basic encodedstring=" -H "Accept: */*" -H "Content-Type: text/plain" -H
"Content-Length: 453" -d "@$data" https://www.xyz.com/csw/servlet/xmlrequest

I get the following error:

# ./post.sh data.txt
<H1>HTTP method GET is not supported by this URL</H1>#

The request appears as a GET in the web logs:

x.x.x.x - - [31/Jul/2003:07:32:44 -0400] "GET /csw/servlet/xmlrequest
HTTP/1.1" 405 53 "-" "curl/7.10.6 (sparc-sun-solaris2.9) libcurl/7.10.6
OpenSSL/0.9.7b zlib/1.1.3" GET /csw/servlet/xmlrequest - "HTTP/1.1"

However if I use the command line with no header information (no
authentication), I get the correct response from the server (an
authentication exception):

# /usr/local/bin/curl -d `cat data.txt`
https://betatest.cswcasa.com/csw/servlet/xmlrequest

<casa>
<message>
<![CDATA[
Authentication Failure
]]>
</message>

This appears correctly in the web logs:

x.x.x.x - - [31/Jul/2003:07:38:07 -0400] "POST /csw/servlet/xmlrequest
HTTP/1.1" 200 906 "-" "curl/7.10.6 (sparc-sun-solaris2.9) libcurl/7.10.6
OpenSSL/0.9.7b zlib/1.1.3" POST /csw/servlet/xmlrequest - "HTTP/1.1"

Any ideas what's going on here?

Thanks,
Jared

-----Original Message-----
From: David Seaman [mailto:dseaman_at_luminet.net]
Sent: Wednesday, July 30, 2003 6:33 PM
To: curl-users_at_lists.sourceforge.net
Subject: Re: https/post help

Jared,
    You want something like:

curl -H "Host: www.xyz.com" -H "Authorization: Basic <encoded authorization
     string here>" -H "Accept: */*" -d @data.txt
https://www.xyz.com/csw/serv
     let/xmlrequest

David

> HI,

> I'm trying to do an https/post of some xml to a url where I'll get a
result
> returned. I'm supposed to include authentication data in the header.
Here's
> what I've done.

> 1. Created a file called header.txt with the following data:

> # cat header.txt
> POST http://www.xyz.com/csw/servlet/xmlrequest HTTP/1.0

> Host: www.xyz.com

> Authorization: Basic <encoded authorization sting here>

> Accept: */*

> Content-Type: text/plain

> Content-Length: 452

> 2. Created a file called data.txt where the post data is URI encoded

> # cat data.txt
>
%3Ccasa%3E%3Caccount%3E%3Ccustomerid%3E1000%3C%2Fcustomerid%3E%3Cuserid%3E49
>
%3C%2Fuserid%3E%3C%2Faccount%3E%3Cproperty%3E%3Cpropstreet%3E18808%20oldhome
>
stead%3C%2Fpropstreet%3E%3Cpropunit%3E%3C%2Fpropunit%3E%3Cpropcity%3Eharper%
>
20woods%3C%2Fpropcity%3E%3Cpropstate%3EMi%3C%2Fpropstate%3E%3Cpropzip%3E4822
>
5%3C%2Fpropzip%3E%3Cproptype%3E%3C%2Fproptype%3E%3C%2Fproperty%3E%3Coptional
>
%3E%3Ctracking%3E%3Ctracknum%3E987654321%3C%2Ftracknum%3E%3Ctrackname%3EJohn
> %20Smith%3C%2Ftrackname%3E%3C%2Ftracking%3E%3C%2Foptional%3E%3C%2Fcasa%3E

> 3. Run the following command and get the following error:

> # /usr/local/bin/curl -b header.txt -f "file=@data.txt"
> https://www.xyz.com/csw/servlet/xmlrequest
> password:
> curl: (6) Couldn't resolve host 'data.txt'
> curl: (22) The requested URL returned error: 405

> Since I'm getting a 405, I know I'm getting to the server, but the 405
tells
> me that the method is not allowed. This server does support POST's.

> Any recommendations?

> Thanks,

> Jared

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-07-31