diff --git a/app/Tygh/Http.php b/app/Tygh/Http.php index aabebab..59804ef 100644 --- a/app/Tygh/Http.php +++ b/app/Tygh/Http.php @@ -455,7 +455,7 @@ class Http * @param string $url request URL * @param string $data request data (URL-encoded) * @param array $extra extra parameters - * @return mixed string response/true if output is written to file or false if request failed + * @return mixed string response or false if request failed */ private static function _socketRequest($method, $url, $data, $extra) { @@ -491,7 +491,7 @@ class Http $post_url = $components['path'] . (!empty($components['query']) ? '?' . $components['query'] : ''); } - fputs($sh, "$method $post_url HTTP/1.0\r\n"); + fputs($sh, "$method $post_url HTTP/1.1\r\n"); fputs($sh, "Host: $components[host]\r\n"); if (!empty($req_settings['proxy_user'])) { @@ -528,36 +528,15 @@ class Http fputs($sh, "\r\n"); } - if (!empty($extra['write_to_file'])) { - $f = fopen($extra['write_to_file'], 'w'); - } - $content = ''; - $headers_parsed = false; while (!feof($sh)) { $content .= fread($sh, 65536); - - if (!empty($extra['write_to_file'])) { - if (!$headers_parsed) { - $headers_parsed = true; - $content = self::_parseContent($content); - } - - fwrite($f, $content); - $content = ''; - } } - fclose($sh); if (!empty($content)) { $content = self::_parseContent($content); } - - if (!empty($extra['write_to_file'])) { - $content = true; - fclose($f); - } } else { self::_setError('socket', $error, $errno); $content = false; @@ -572,7 +551,7 @@ class Http * @param string $url request URL * @param string $data request data (URL-encoded) * @param array $extra extra parameters - * @return mixed string response/true if output is written to file or false if request failed + * @return mixed string response or false if request failed */ private static function _curlRequest($method, $url, $data, $extra) { @@ -627,12 +606,6 @@ class Http curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - if (!empty($extra['write_to_file'])) { - $f = fopen($extra['write_to_file'], 'w'); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_FILE, $f); - } - $req_settings = self::_getSettings(); if (!empty($req_settings['proxy_host'])) { curl_setopt($ch, CURLOPT_PROXY, $req_settings['proxy_host'] . ':' . (empty($req_settings['proxy_port']) ? 3128 : $req_settings['proxy_port'])); @@ -660,10 +633,6 @@ class Http self::_setError('curl', $error, $errno); } - if (!empty($extra['write_to_file'])) { - fclose($f); - } - return $content; }