Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.2.2

Bug #9506 Use HTTP_Request to know if an URI is valid
Submitted: 2006-11-30 03:42 UTC
From: pfischer at php dot net Assigned: firman
Status: Closed Package: Services_Pingback (version 0.2.0dev2)
PHP Version: 5.1.6 OS: Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 28 + 43 = ?

 
 [2006-11-30 03:42 UTC] pfischer at php dot net (Pablo Fischer)
Description: ------------ Hi, First of all, thanks for your package, we are using it @ Jaws Project for supporting pingback. The reason of this 'bug report' is to let you know a little bug I found. Currently you validate an URI by calling fopen which is *OK*, however fopen has some limitations with some URLs (like those that use query strings or path info: index.php/foo/bar). And example of this happens when the discover/source/target URIs are very similar to http://www.example.com/index.php/foo/bar (using PATH_INFO). With the current release it will return false which is not correct cause maybe the sourceURI/targetURI uses PATH_INFO (like WP/Jaws/others). So, the most *reasonable* way to fix this is to do the same that RPC (and some parts of Pingback) does: use fsockopen/HTTP_Request which does: 1. Open a socket (fsockopen) 2. Get headers 3. If responseCode == 200 then the URI is valid. I'm sending a patch for this (already tested with some WP/Jaws posts). Thanks for the package! Test script: --------------- function isURIExist($uri) { $params = array( 'timeout' => 3, 'allowRedirects' => true, 'maxRedirects' => 2, ); $req = new HTTP_Request($uri, $params); $req->sendRequest(); if (PEAR::isError($req)) { return false; } if ($req->getResponseCode() == 200) { return true; } return false; }

Comments

 [2006-12-06 22:49 UTC] firman (Firman Wandayandi)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.