I know what gainpaulo post, should be the way it's supposed to work;
however, i was able to get it to work with a GET, but not a POST:


                $request_get = array(
                        'GET http://www.google.com HTTP/1.1',
                        'Host: www.google.com',
                        'Connection: close',
                        'User-Agent: CakePHP'
                        );
                $response = $HttpSocket->request(array(
                        'host' => "$proxyhost:$proxyport",
                        'line' => implode("\n", $request_get),
                        'raw' => implode("\n", $request_get),
                        ));
                print_r($response);
                print_r($HttpSocket->request);
                print_r($HttpSocket->config);

                $request_post = array(
                        'POST http://www.google.com HTTP/1.1',
                        'q=cakephp',
                        'Host: www.google.com',
                        'Connection: close',
                        'User-Agent: CakePHP'
                        );
                $response = $HttpSocket->request(array(
                        'host' => "$proxyhost:$proxyport",
                        'line' => implode("\n", $request_post),
                        'raw' => implode("\n", $request_post),
                        ));
                print_r($response);
                print_r($HttpSocket->request);
                print_r($HttpSocket->config);

On Dec 15, 10:21 am, fr3nch13 <fr3nc...@gmail.com> wrote:
> Also, some more information.
> 1. i don't have access to change anything on the squid proxy.
> 2. trying with curl works:
>     curl --proxy [proxyhostname]:[port]http://www.google.com
>
> On Dec 15, 10:18 am, fr3nch13 <fr3nc...@gmail.com> wrote:
>
> > It doesn't seem to be working.
> > Any help would be greatly appreciated!
>
> > Here is some more information/versions/stats to help:
>
> > Server: RHEL, PHP 5.1.6, cakephp 1.2.3.8166
> > Proxy: Squid/2.5 stable
>
> > This is my test shell:
> > <?php
>
> > class TesterShell extends Shell
> > {
>
> >         function httpsockproxy()
> >         {
> >                 $uri = 'http://www.google.com';
>
> >                 if(isset($this->args[0]))
> >                 {
> >                         $uri = $this->args[0];
> >                 }
>
> >                 App::import('Core', 'HttpSocket');
> >                 $HttpSocket = new HttpSocket();
>
> >                 $request = $HttpSocket->request(array(
> >                         'method' => 'POST',
> >                         'host'=>'[proxyhostname]:[port]',
> >                         'uri'=>'http://www.google.com'
> >                         ));
> >                 print_r($request);
> >                 print_r($HttpSocket->config);
> >         }
>
> > }
>
> > the print_r($request) is getting a response from the squid proxy
> > server; however, the proxy is returning it's html error instead of
> > google's homepage:
>
> > ...
> > <H2>The requested URL could not be retrieved</H2>
> > <HR noshade size="1px">
> > <P>
> > While trying to retrieve the URL:
> > <A HREF="/">/</A>
> > <P>
> > The following error was encountered:
> > <UL>
> > <LI>
> > <STRONG>
> > Invalid URL
> > </STRONG>
> > </UL>
> > ....
>
> > the print_r($HttpSocket->config) output is:
> > Array
> > (
> >     [persistent] =>
> >     [host] => [proxyhostname]:[port]
> >     [protocol] => 6
> >     [port] => 80
> >     [timeout] => 30
> >     [request] => Array
> >         (
> >             [uri] => Array
> >                 (
> >                     [scheme] => http
> >                     [host] =>www.google.com
> >                     [port] => 80
> >                 )
>
> >             [auth] => Array
> >                 (
> >                     [method] => Basic
> >                     [user] =>
> >                     [pass] =>
> >                 )
>
> >             [cookies] => Array
> >                 (
> >                 )
>
> >         )
>
> > )
>
> > On Dec 15, 8:56 am, fr3nch13 <fr3nc...@gmail.com> wrote:
>
> > > Thanks!
>
> > > I'll try this out and let this group know if it was successful.
>
> > > On Dec 14, 10:04 pm, gianpaulo <gcbasa...@gmail.com> wrote:
>
> > > > Try this:
>
> > > > $HttpSocket = new HttpSocket();
> > > > $request = $HttpSocket->request(array(
> > > >    'host'=>'<proxy server address>:<proxy server port>',
> > > >    'uri'=>'http://api.yahoo.com/'
> > > > ));
>
> > > > This is how powerful CakePHP is :D
>
> > > > On Dec 15, 8:48 am, fr3nch13 <fr3nc...@gmail.com> wrote:
>
> > > > > Has anyone tried using a proxy server with HttpSocket?
>
> > > > > I have been looking all over via the normal channels (google, api,
> > > > > bakery, book, etc.) to no avail.
>
> > > > > If so, could you please point me in the right direction?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to