Re: How to include 'Host:' and relative URI in request header
Gisle Aas (gisle@activestate.com)
11 Apr 2001 13:05:10 -0700
MrLarf9@aol.com writes:
> I have desperately spent the last 7 days attempting to figure out how to send
> the following two lines in an HTTP request using libwww (LWP::UserAgent,
> HTTP::Request, etc.):
>
> POST /ABCApp/TransactionInterface5_0/DServlet HTTP/1.1
> Host: test.server.com:4321
If you do a:
my $req = HTTP::Request->new(POST => "http://test.server.com:4321/ABCApp/TransactionInterface5_0/DServlet");
$req->content("...");
and then send it off, this should be exactly what you get on the wire.
The only difference is that you get HTTP/1.0 instead of HTTP/1.1.
LWP-5.53 contains a HTTP/1.1 protocol module so you can get that too.
> I need this to be sent to the server as the request in order to be able to
> send some XML data and receive a response. Libwww is perfect for this -
> except for the fact that I cannot figure out how to send this header
> (although this header indicates HTTP 1.1, I only need to fool the "server"
> into believing this) I actually do not require any HTTP 1.1 functionality -
> EXCEPT for that pesky Host: header field.
>
> One of the stumbling blocks along the way has been the fact that I need to
> send a relative URI in the POST - and when I run my little script - I am hit
> with a "400 URL must be absolute" error. How can I make this request send a
> relative URI (for XML's sake) and use the Host: header field to put together
> a complete URL to connect to.
"400 URL must be absolute" sounds more like you should give it an
absolute URI instead of a relative.
Regards,
Gisle