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

Request #15424 Add a verbose or debug mode that would log the request/response to stdout
Submitted: 2008-12-28 12:11 UTC
From: izi Assigned: avb
Status: Closed Package: HTTP_Request2 (version 0.1.0)
PHP Version: 5.2.6 OS: openbsd
Roadmaps: 0.2.0    
Subscription  


 [2008-12-28 12:11 UTC] izi (David Jean Louis)
Description: ------------ It would be great for debugging/testing purposes to have some sort of verbose / debug mode in HTTP_Request2 (ala curl). I know this can be achieved with a custom listener, but it would be great if HTTP_Request2 provided this out of the box. Test script: --------------- <?php require_once 'HTTP/Request2'; $request = new HTTP_Request2( 'http://example.com/index.php?foo=bar', 'GET', array('verbose' => true), // or debug, or whatever ); $request->send(); ?> Expected result: ---------------- stdout output: =========== > GET /index.php?foo=bar HTTP/1.1 > User-Agent: HTTP_Request2/0.1.0 ... > Host: example.com > Accept: */* > < HTTP/1.1 404 Not Found < Date: Sun, 28 Dec 2008 12:04:19 GMT < Server: Apache/2.2.3 (CentOS) < Content-Length: 283 < Connection: close < Content-Type: text/html; charset=iso-8859-1 < <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /index.php was not found on this server.</p> <hr> <address>Apache/2.2.3 (CentOS) Server at example.com Port 80</address> </body></html>

Comments

 [2008-12-28 13:10 UTC] avb (Alexey Borzov)
As you mentioned, this can be achieved with a custom listener, so no point adding functionality to the base class(es) that will only be used when debugging. On the other hand, if someone writes such a custom debug listener, I'll gladly add it to the package!
 [2008-12-28 13:12 UTC] izi (David Jean Louis)
Alexey, I'll see what I can do and ping you when I have something up... -- David
 [2008-12-28 19:17 UTC] izi (David Jean Louis)
Hi Alexey, I added the package.xml patch + the file (in txt format) to put in a new Request2/Observer/ directory. -- David
 [2009-01-02 16:30 UTC] avb (Alexey Borzov)
Thank you! Committed the class (with some changes).