mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-12 03:16:34 +00:00
Reduce number of ops
This commit is contained in:
+17
-12
@@ -708,23 +708,26 @@ class Curl
|
||||
{
|
||||
$name_chars = array();
|
||||
foreach (str_split($key) as $name_char) {
|
||||
if (!isset($this->rfc2616[$name_char])) {
|
||||
$name_chars[] = rawurlencode($name_char);
|
||||
} else {
|
||||
if (isset($this->rfc2616[$name_char])) {
|
||||
$name_chars[] = $name_char;
|
||||
} else {
|
||||
$name_chars[] = rawurlencode($name_char);
|
||||
}
|
||||
}
|
||||
|
||||
$value_chars = array();
|
||||
foreach (str_split($value) as $value_char) {
|
||||
if (!isset($this->rfc6265[$value_char])) {
|
||||
$value_chars[] = rawurlencode($value_char);
|
||||
} else {
|
||||
if (isset($this->rfc6265[$value_char])) {
|
||||
$value_chars[] = $value_char;
|
||||
} else {
|
||||
$value_chars[] = rawurlencode($value_char);
|
||||
}
|
||||
}
|
||||
|
||||
$this->cookies[implode('', $name_chars)] = implode('', $value_chars);
|
||||
|
||||
// Avoid using http_build_query() as unnecessary encoding is performed.
|
||||
// http_build_query($this->cookies, '', '; ');
|
||||
$this->setOpt(CURLOPT_COOKIE, implode('; ', array_map(function ($k, $v) {
|
||||
return $k . '=' . $v;
|
||||
}, array_keys($this->cookies), array_values($this->cookies))));
|
||||
@@ -741,25 +744,27 @@ class Curl
|
||||
foreach ($cookies as $key => $value) {
|
||||
$name_chars = array();
|
||||
foreach (str_split($key) as $name_char) {
|
||||
if (!isset($this->rfc2616[$name_char])) {
|
||||
$name_chars[] = rawurlencode($name_char);
|
||||
} else {
|
||||
if (isset($this->rfc2616[$name_char])) {
|
||||
$name_chars[] = $name_char;
|
||||
} else {
|
||||
$name_chars[] = rawurlencode($name_char);
|
||||
}
|
||||
}
|
||||
|
||||
$value_chars = array();
|
||||
foreach (str_split($value) as $value_char) {
|
||||
if (!isset($this->rfc6265[$value_char])) {
|
||||
$value_chars[] = rawurlencode($value_char);
|
||||
} else {
|
||||
if (isset($this->rfc6265[$value_char])) {
|
||||
$value_chars[] = $value_char;
|
||||
} else {
|
||||
$value_chars[] = rawurlencode($value_char);
|
||||
}
|
||||
}
|
||||
|
||||
$this->cookies[implode('', $name_chars)] = implode('', $value_chars);
|
||||
}
|
||||
|
||||
// Avoid using http_build_query() as unnecessary encoding is performed.
|
||||
// http_build_query($this->cookies, '', '; ');
|
||||
$this->setOpt(CURLOPT_COOKIE, implode('; ', array_map(function ($k, $v) {
|
||||
return $k . '=' . $v;
|
||||
}, array_keys($this->cookies), array_values($this->cookies))));
|
||||
|
||||
Reference in New Issue
Block a user