Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I know how to use the LWP module to pass data through a proxy but I want to know if there is a way to pass data through a proxy over a raw socket without using the LWP module. Basically I want to create an HTTP client without using the LWP module because I want more control over the data flow. Any help is appreciated.

Replies are listed 'Best First'.
Re: Proxy in Perl
by arthas (Hermit) on Jun 02, 2003 at 13:09 UTC
    You'll have to open a connection with port 80 (or whatever port it listens) of your proxy sever. The Socket module will do that for you. After that, you'll just need to request the page you want to the proxy, by sending it a string such as:
    GET http://www.siteyouwant.com/pageyouneed.html HTML/1.1
    The proxy will look into its database if it has a current copy of the page, otherwise it will request it to the web server. Then, the page will be served to your client over the connection you created.

    Michele.
      Hi Michele. The proxy that I am using works a little differently as it does not store anything locally to the box. It works more like a stateful inspection firewall. The request gets sent to the proxy (firewall) and then the proxy checks to see if its ok to send the request out to the "wild." I tried using the LWP:PROXY module which worked fine but I want to manipulate some of the TCP/IP packet information for some experimental purposes in which case the LWP module is not sufficient. Hopefully this is enough information (and its clear). Again, any help is appreciated.

        manipulate some of the TCP/IP packet information
        I hope this helps:

        NetPacket::TCP
        Assemble and disassemble TCP (Transmission Control Protocol) packets.

Re: Proxy in Perl
by Juerd (Abbot) on Jun 02, 2003 at 13:27 UTC
•Re: Proxy in Perl
by merlyn (Sage) on Jun 02, 2003 at 16:17 UTC
    How much "more control" do you need? Are you aware of the ability to set arbitary headers, and use callbacks to get the data as it comes in?

    If you had any more control than what LWP provides you, it wouldn't be HTTP any more! In which case, your query is misstated.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.