develooper Front page | perl.libwww | Postings from April 2001

Re: How to include 'Host:' and relative URI in request header

Thread Previous | Thread Next
April 12, 2001 11:37
Re: How to include 'Host:' and relative URI in request header
Message ID:
Thank you Mr. Aas,

First of all, I want you to know what an honor it was to receive a response from you. Second - there is still work to be done :) 

> If you do a:

>   my $req = HTTP::Request->new(POST =>
>   $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.

The above is perfect and clear.  It was one of the first things i tried after playing with UserAgent.  However, the pesky '' refuses to receive a request unless it:

1. Has a POST request line with a relative URI and a declaration of the HTTP 1.1 protocol
'POST /ABCApp/TransactionInterface5_0/DServlet HTTP/1.1'

2. Has a 'Host:' header containing the hostname and port #.

I have no control over the configuration of this server - I simply have the requirements needed to communicate with it.  As you see I am pretty stuck, since Perl is the only language I am vaguely familiar with.  I know what I need can be done with Java or as a COM object in win32, but I would faster learn fluent Japanese than tinker with these complex mysterons.

I did achieve a successful connection to this server via IO::Socket, but that's all I was able to do.  From my hazy perspective, the socket module does not facilitate the sending or receiving of data - it simply creates the connection.  
I also know that IO:Socket is used by UserAgent - which can handle the request and response - but I face a small dilemma:  I can create a new IO:Socket object to establish a connection, but how can I create a new UserAgent object (to handle the request and response) in the same script without LWP::UserAgent->new() trying to create that connection again.

I hope this is clear.  I guess the question is - Can one script "tell" IO::Socket that:
$uri = '/ABCApp/TransactionInterface5_0/DServlet';
$proto = 'HTTP 1.1'
PeerPort = '(4321)'
PeerAddr = ''
and use the above information when launching a new UserAgent, which will then make the connection using the relative URI, as well as send and receive xml data.

This is the only solution I see so far.  Please let me know if such a thing is feasible.  If not - can it be done in Perl at all?  

I thank you in advance.  Any words of wisdom are greatly appreciated.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About