Commit 0b18fc12 authored by mikeytown2's avatar mikeytown2

Issue #1918728 by mikeytown2: Use strlen when possible for performance...

Issue #1918728 by mikeytown2: Use strlen when possible for performance reasons. Also do not dive deep in printing function if object has __set magic method.
parent 4446c150
......@@ -591,9 +591,8 @@ function httprl_handle_data(&$options) {
// or PUT request. Some non-standard servers get confused by Content-Length in
// at least HEAD/GET requests, and Squid always requires Content-Length in
// POST/PUT requests.
$content_length = httprl_strlen($options['data']);
if ($content_length > 0 || $options['method'] == 'POST' || $options['method'] == 'PUT') {
$options['headers']['Content-Length'] = $content_length;
if (strlen($options['data']) > 0 || $options['method'] == 'POST' || $options['method'] == 'PUT') {
$options['headers']['Content-Length'] = httprl_strlen($options['data']);
}
}
......@@ -1312,7 +1311,7 @@ function httprl_send_request($results = NULL) {
// Read socket.
$chunk = fread($r, $responses[$id]->chunk_size);
if (httprl_strlen($chunk) > 0) {
if (strlen($chunk) > 0) {
$rw_done = TRUE;
if (!isset($responses[$id]->time_to_first_byte)) {
// Calculate Time to First Byte.
......@@ -1372,7 +1371,7 @@ function httprl_send_request($results = NULL) {
// Get stream data.
$info = stream_get_meta_data($r);
$alive = !$info['eof'] && !feof($r) && !$info['timed_out'] && httprl_strlen($chunk);
$alive = !$info['eof'] && !feof($r) && !$info['timed_out'] && strlen($chunk);
if (!$alive) {
if ($responses[$id]->status == 'Connecting.') {
$responses[$id]->error = $t('Connection refused by destination. TCP.');
......@@ -2402,7 +2401,7 @@ function httprl_lock_release($name) {
function httprl_print_empty(&$data, $level = 0) {
$level++;
if ($level < 10 ) {
if (is_object($data)) {
if (is_object($data) && !method_exists($data, '__set')) {
foreach ($data as $key => $values) {
$data->{$key} = httprl_print_empty($values, $level);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment