Zend_Gdata_App_LoggingHttpClientAdapterSocket

Overrides the traditional socket-based adapter class for Zend_Http_Client to enable logging of requests.

Defined (1)

The class is defined in the following location(s).

/inc/VideoUploader/includes/Zend/Gdata/App/LoggingHttpClientAdapterSocket.php  
  1. class Zend_Gdata_App_LoggingHttpClientAdapterSocket extends Zend_Http_Client_Adapter_Socket 
  2.  
  3. /** 
  4. * The file handle for writing logs 
  5. * @var resource|null 
  6. */ 
  7. protected $log_handle = null; 
  8.  
  9. /** 
  10. * Log the given message to the log file. The log file is configured 
  11. * as the config param 'logfile'. This method opens the file for 
  12. * writing if necessary. 
  13. * @param string $message The message to log 
  14. */ 
  15. protected function log($message) 
  16. if ($this->log_handle == null) { 
  17. $this->log_handle = fopen($this->config['logfile'], 'a'); 
  18. fwrite($this->log_handle, $message); 
  19.  
  20. /** 
  21. * Connect to the remote server 
  22. * @param string $host 
  23. * @param int $port 
  24. * @param boolean $secure 
  25. * @param int $timeout 
  26. */ 
  27. public function connect($host, $port = 80, $secure = false) 
  28. $this->log("Connecting to: ${host}:${port}"); 
  29. return parent::connect($host, $port, $secure); 
  30.  
  31. /** 
  32. * Send request to the remote server 
  33. * @param string $method 
  34. * @param Zend_Uri_Http $uri 
  35. * @param string $http_ver 
  36. * @param array $headers 
  37. * @param string $body 
  38. * @return string Request as string 
  39. */ 
  40. public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '') 
  41. $request = parent::write($method, $uri, $http_ver, $headers, $body); 
  42. $this->log("\n\n" . $request); 
  43. return $request; 
  44.  
  45. /** 
  46. * Read response from server 
  47. * @return string 
  48. */ 
  49. public function read() 
  50. $response = parent::read(); 
  51. $this->log("${response}\n\n"); 
  52. return $response; 
  53.  
  54. /** 
  55. * Close the connection to the server 
  56. */ 
  57. public function close() 
  58. $this->log("Closing socket\n\n"); 
  59. parent::close(); 
  60.