includes/http.php
changeset 349 fdaf9070566c
parent 328 dc838fd61a06
child 354 979d99a0b00e
--- a/includes/http.php	Wed Jan 16 13:55:49 2008 -0500
+++ b/includes/http.php	Thu Jan 17 02:03:33 2008 -0500
@@ -324,24 +324,11 @@
   
   function _sock_open(&$connection)
   {
-    if ( $this->debug )
-    {
-      echo '<hr /><div style="white-space: nowrap;">';
-      echo '<p><b>' . __CLASS__ . ': Sending request</b></p><p>Request parameters:</p>';
-      echo "<p><b>Headers:</b></p><pre>$headers</pre>";
-      echo "<p><b>Cookies:</b> $cookies</p>";
-      echo "<p><b>GET URI:</b> " . htmlspecialchars($get) . "</p>";
-      echo "<p><b>POST DATA:</b> " . htmlspecialchars($post) . "</p>";
-    }
-    
     // Open connection
     $connection = fsockopen($this->host, $this->port);
     if ( !$connection )
       die(__CLASS__ . '::' . __METHOD__ . ': Could not make connection');
     
-    if ( $this->debug )
-      echo '<p>Connection opened. Writing main request to socket. Raw socket data follows.</p><pre>';
-    
     // 1 = socket open
     $this->state = 1;
   }
@@ -355,6 +342,20 @@
   {
     $newline = "\r\n";
     
+    if ( $this->debug )
+      echo '<p>Connection opened. Writing main request to socket. Raw socket data follows.</p><pre>';
+    
+    if ( $this->debug )
+    {
+      echo '<hr /><div style="white-space: nowrap;">';
+      echo '<p><b>' . __CLASS__ . ': Sending request</b></p><p>Request parameters:</p>';
+      echo "<p><b>Headers:</b></p><pre>$headers</pre>";
+      echo "<p><b>Cookies:</b> $cookies</p>";
+      echo "<p><b>GET URI:</b> " . htmlspecialchars($this->uri . $get) . "</p>";
+      echo "<p><b>POST DATA:</b> " . htmlspecialchars($post) . "</p>";
+    }
+    echo "<pre>";
+    
     $this->_fputs($connection, "{$this->method} {$this->uri}{$get} HTTP/1.1{$newline}");
     $this->_fputs($connection, "Host: {$this->host}{$newline}");
     $this->_fputs($connection, $headers);
@@ -393,7 +394,7 @@
     if ( $this->debug )
     {
       echo '<p>Response fetched. Closing connection. Response text follows.</p><pre>';
-      echo htmlspecialchars($buffer);
+      echo htmlspecialchars($this->response);
       echo '</pre></div><hr />';
     }