summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_url.class9
1 files changed, 7 insertions, 2 deletions
diff --git a/it_url.class b/it_url.class
index 4c8a80d..87caa33 100644
--- a/it_url.class
+++ b/it_url.class
@@ -155,6 +155,8 @@ function _get($p = [], $timeout = null)
if ($p['assoc'])
$result = $result !== false ? [ 'status' => $this->result, 'data' => $this->data, 'headers' => $this->headers, 'cookies' => $this->cookies, 'errstr' => $this->errstr ] : [];
+ EDC('curlinfo', $this->result, $this->headers, $this->cookies, $this->errstr);
+
return $result;
}
@@ -181,10 +183,11 @@ static function _default_headers($url, $p)
$headers = array_filter([
'Host' => $url->realhostname . $url->explicitport,
'User-Agent' => "Mozilla/5.0 (compatible; ITools; Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582)",
- 'Accept-Language' => $p['headers']['Accept-Language'] ?: ($search_subrequest ? T_defaultlang() : T_lang()), # can prevent loading of it_text
+ 'Accept-Language' => $p['headers']['Accept-Language'] ?? ($search_subrequest ? T_defaultlang() : T_lang()), # can prevent loading of it_text
'Referer' => it::match('([-\w]+\.\w+)$', $url->hostname) == it::match('([-\w]+\.\w+)$', $_SERVER['HTTP_HOST']) ? it_url::absolute(U($_GET)) : null,
'X-Ultra-Https' => $_SERVER['HTTPS'],
]);
+
if (is_int($p['filemtime']))
$headers['If-Modified-Since'] = date("r", $p['filemtime']);
return $headers;
@@ -227,6 +230,8 @@ static function curl_opts($p=array())
if ($p['sslcert'])
$add += [CURLOPT_SSLCERT => $p['sslcert']];
+ $add += $p['curlinfo'] ? [CURLINFO_HEADER_OUT => 1] : [];
+
if ($p['verbose'] || EDC('curlverbose'))
$add += [ CURLOPT_VERBOSE => true ];
@@ -268,7 +273,7 @@ function request($p=array())
$this->errstr = "";
$url->headers = array();
- $p['headers'] = (array)$p['headers'] + self::_default_headers($url, $p);
+ $p['headers'] = array_filter((array)$p['headers'] + self::_default_headers($url, $p), 'strlen');
$opts = self::curl_opts($p + array('user' => $this->user, 'pass' => $this->pass, 'followlocation' => false));
if ($p['verbose'])
{