aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-10-12 04:28:47 +0000
committerMario <mario@mariovavti.com>2018-10-12 10:56:28 +0200
commitf7834547744d232091b966b24b9d2e95bda97681 (patch)
tree79353945d8b1d9dd093def2eee9f0a7d448c78de /include
parent2ab6e0843d199df5611072725bcabf76a518f9e9 (diff)
downloadvolse-hubzilla-f7834547744d232091b966b24b9d2e95bda97681.tar.gz
volse-hubzilla-f7834547744d232091b966b24b9d2e95bda97681.tar.bz2
volse-hubzilla-f7834547744d232091b966b24b9d2e95bda97681.zip
verify some edge case http signatures
(cherry picked from commit c6bfd5e7befedf79ab6f7e70902e5fb2aa69fa6f)
Diffstat (limited to 'include')
-rw-r--r--include/network.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/network.php b/include/network.php
index 5ae02deff..4c9813768 100644
--- a/include/network.php
+++ b/include/network.php
@@ -48,6 +48,10 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
if(($redirects > 8) || (! $ch))
return $ret;
+ if(! array_key_exists('request_target',$opts)) {
+ $opts['request_target'] = 'get ' . get_request_string($url);
+ }
+
@curl_setopt($ch, CURLOPT_HEADER, true);
@curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@curl_setopt($ch, CURLOPT_CAINFO, get_capath());
@@ -179,6 +183,7 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
}
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
+ $ret['request_target'] = $opts['request_target'];
if(x($opts,'debug')) {
$ret['debug'] = $curl_info;
@@ -227,6 +232,10 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) {
if(($redirects > 8) || (! $ch))
return $ret;
+ if(! array_key_exists('request_target',$opts)) {
+ $opts['request_target'] = 'get ' . get_request_string($url);
+ }
+
@curl_setopt($ch, CURLOPT_HEADER, true);
@curl_setopt($ch, CURLINFO_HEADER_OUT, true);
@curl_setopt($ch, CURLOPT_CAINFO, get_capath());
@@ -359,6 +368,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) {
$ret['body'] = substr($s, strlen($header));
$ret['header'] = $header;
+ $ret['request_target'] = $opts['request_target'];
if(x($opts,'debug')) {
$ret['debug'] = $curl_info;
@@ -2080,3 +2090,17 @@ function jsonld_document_loader($url) {
return [];
}
+
+/**
+ * @brief Given a URL, return everything after the host portion.
+ * example https://foobar.com/gravy?g=5&y=6
+ * returns /gravy?g=5&y=6
+ * result always returns the leading slash
+ */
+
+function get_request_string($url) {
+
+ $a = explode('/',$url,4);
+ return '/' . ((count($a) > 3) ? $a[3] : EMPTY_STR);
+
+}