in reply to Re: Sending unmatched HTTP Responses
in thread Sending unmatched HTTP Responses

The problem with HTTP:Response is that it allows you to construct an HTTP:Response, or receive one from LWP::UserAgent, but it doesn't allow you to SEND an HTTP::Response.

I suppose my problem is that LWP::UserAgent doesn't seem to want to let me send an HTTP::Response. Which is generally perfectly reasonable, but would be useful right now.

Replies are listed 'Best First'.
Re^3: Sending unmatched HTTP Responses
by Corion (Patriarch) on Oct 29, 2009 at 11:29 UTC

    Without knowing your further framework, it's hard to advise how to actually send the response. In the simplest way, you would get the client socket from your framework and do

    print {$client_socket} $my_faked_response->as_string;

    which would send the response to your client. Alternatively, look at HTTP::Proxy, which you can use to sit in between your client and the actual server to inject your own responses.

Re^3: Sending unmatched HTTP Responses
by almut (Canon) on Oct 29, 2009 at 11:48 UTC

    Maybe you could take Apache out of the picture entirely (for testing purposes) and run a simple Perl webserver, such as HTTP::Server::Simple. Then you could essentially send anything you want, without having to mess with Apache's standard request cycle...

    But, as Corion said, it's a little hard to be more specific, without knowing what exactly you need to do.  In other words, if Apache is a constituent to be included in the testing, this won't work of course.