diff --git a/httprl.module b/httprl.module index 5f0149b..fee8304 100644 --- a/httprl.module +++ b/httprl.module @@ -294,6 +294,7 @@ function httprl_set_default_options(&$options) { 'chunk_size_read' => 32768, 'chunk_size_write' => 1024, 'async_connect' => TRUE, + 'head_only' => FALSE, ); // Merge the default headers. @@ -785,6 +786,9 @@ 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 @@ -1173,6 +1177,15 @@ 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); + } } }