diff --git a/httprl.module b/httprl.module index fee8304..4de2daf 100644 --- a/httprl.module +++ b/httprl.module @@ -21,8 +21,7 @@ define('HTTPRL_GLOBAL_TIMEOUT', 120.0); define('HTTPRL_REQUEST_ALLOWED_REDIRECTS_EXHAUSTED', -2); /** - * Error code indicating that the request made by httprl_request() exceeded - * the maximum allowed redirects without reaching the final target. + * Error code indicating that the call to fwrite() failed. */ define('HTTPRL_REQUEST_FWRITE_FAIL', -3); @@ -294,7 +293,6 @@ function httprl_set_default_options(&$options) { 'chunk_size_read' => 32768, 'chunk_size_write' => 1024, 'async_connect' => TRUE, - 'head_only' => FALSE, ); // Merge the default headers. @@ -786,9 +784,6 @@ function httprl_establish_stream_connection(&$result) { * - version: HTTP Version 1.0 or 1.1. Default is 1.0 for a good reason. * - referrer: TRUE - send current page; FALSE - do not send current * page. Default is FALSE. - * - head_only: FALSE (default) - Get the whole request. TRUE - Cut the - * connection once we have the headers and discard any data that we might - * have gotten. * - domain_connections: Maximum number of simultaneous connections to a given * domain name. Default is 8. * - global_connections: Maximum number of simultaneous connections that can @@ -887,6 +882,11 @@ function httprl_request($urls, $options = array()) { // Build the request string. $request = httprl_build_request_string($uri, $options); + // If a range header is set, calculate how many bytes need to be downloaded. + if (!empty($options['headers']['Range'])) { + $options['max_data_size'] = ''; + } + // Put all variables into an array for easy alterations. $connections[] = array($socket, $flags, $uri, $url, $options, $result, $request); $return[$url] = TRUE; @@ -1177,15 +1177,6 @@ function httprl_send_request($results = NULL) { // Now that we have the headers, increase the chunk size. $responses[$id]->chunk_size = $responses[$id]->options['chunk_size_read']; - - // We only care about the headers. Close Connection. - if ($responses[$id]->options['head_only']) { - $responses[$id]->data = ''; - $responses[$id]->status = 'Done.'; - - // Do post processing on the stream. - httprl_post_processing($id, $responses, $output); - } } }