thanks for the watchful eye, while it's only a very small, negligible
improvement, i'll still take it :) Fix's been committed

On Thu, Nov 20, 2008 at 6:38 PM, Ropu <[EMAIL PROTECTED]> wrote:

> hi,
>
> a performance tip!
>
> *Tip*
>
> preg_split() <http://us3.php.net/manual/en/function.preg-split.php>, which
> uses a Perl-compatible regular expression syntax, is often a faster
> alternative to *split()*. If you don't require the power of regular
> expressions, it is faster to use
> explode()<http://us3.php.net/manual/en/function.explode.php>,
> which doesn't incur the overhead of the regular expression engine.
>
>
> since we are looking just for a string '://' not a patter, explode() y a
> better choice.
>
> and i would use the 3rd param of the explode() function since we only need
> 2
> chunks
>
>
> +               $protocolSplit = explode(":\/\/", $url, 2);
>
> just not that the return is different
>
> Return Values
>
> If *delimiter* is an empty string (""), *explode()* will return *FALSE*. If
> *delimiter* contains a value that is not contained in *string* , then *
> explode()* will return an array containing *string* .
>
>
> so you need to check that count() > 1
> my 2 cents
>
> ropu
>
>
> On Tue, Nov 18, 2008 at 11:04 PM, <[EMAIL PROTECTED]> wrote:
>
> > Author: chabotc
> > Date: Wed Nov 19 01:04:25 2008
> > New Revision: 718911
> >
> > URL: http://svn.apache.org/viewvc?rev=718911&view=rev
> > Log:
> > SHINDIG-662 by Tim Wintle - Check protocol for proxy requests
> >
> > Modified:
> >    incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php
> >
> > Modified: incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php?rev=718911&r1=718910&r2=718911&view=diff
> >
> >
> ==============================================================================
> > --- incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php (original)
> > +++ incubator/shindig/trunk/php/src/gadgets/ProxyHandler.php Wed Nov 19
> > 01:04:25 2008
> > @@ -338,8 +338,19 @@
> >        private function fetchContent($url, $method)
> >        {
> >                //TODO get actual character encoding from the request
> > -
> >
> > +               // Check the protocol requested - curl doesn't really
> > support file://
> > +               // requests but the 'error' should be handled properly
> > +               $protocolSplit = split(":\/\/", $url);
> > +               if (!count($protocolSplit)) {
> > +                       throw new Exception("Invalid protocol specified
> for
> > url: $url");
> > +               } else {
> > +                       $protocol = strtoupper($protocolSplit[0]);
> > +                       if ($protocol != "HTTP" && $protocol != "HTTPS"
> &&
> > $protocol != "FTP") {
> > +                               throw new Exception("Invalid protocol
> > specified in url ($protocol)");
> > +                       }
> > +               }
> > +
> >                // Extract the request headers from the $_SERVER
> > super-global (this -does- unfortunatly mean that any header that php
> doesn't
> > understand won't be proxied thru though)
> >                // if this turns out to be a problem we could add support
> > for HTTP_RAW_HEADERS, but this depends on a php.ini setting, so i'd
> rather
> > prevent that from being required
> >                $headers = '';
> >
> >
> >
>
>
> --
> .-. --- .--. ..-
> R  o  p  u
>

Reply via email to