diff options
author | Urban Müller | 2022-01-20 20:24:41 +0100 |
---|---|---|
committer | Urban Müller | 2022-01-20 20:24:41 +0100 |
commit | 675a224fc7c03b7341a84a7d5d968c89ff557704 (patch) | |
tree | 0fab663a99f5d5e81b7da727da0d2b03e5b73e0c /it_url.class | |
parent | 4125c47e4ce706ba07e52d3dd3285acc7c410228 (diff) | |
download | itools-675a224fc7c03b7341a84a7d5d968c89ff557704.tar.gz itools-675a224fc7c03b7341a84a7d5d968c89ff557704.tar.bz2 itools-675a224fc7c03b7341a84a7d5d968c89ff557704.zip |
enable omitting Accept-Language, show in and out headers in with curlinfo
Diffstat (limited to 'it_url.class')
-rw-r--r-- | it_url.class | 9 |
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']) { |