aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/HTTP/DokuHTTPClient.php
diff options
context:
space:
mode:
authorMichael Große <mic.grosse@googlemail.com>2019-03-26 22:05:09 +0100
committerMichael Große <mic.grosse@googlemail.com>2019-03-26 22:05:09 +0100
commit5a8d6e48ea57255f66cd0126355f1b73f1000de9 (patch)
treed3d2d6819a16aae3a5ade489b92b52c90b12e263 /inc/HTTP/DokuHTTPClient.php
parent0efa8d12f0f39c5cbb24a0cef8671d22119994dd (diff)
downloaddokuwiki-5a8d6e48ea57255f66cd0126355f1b73f1000de9.tar.gz
dokuwiki-5a8d6e48ea57255f66cd0126355f1b73f1000de9.zip
Rename HTTPClient namespace to HTTP
This should make namespace a bit more flexible in scope and allow us to move more functionality there later.
Diffstat (limited to 'inc/HTTP/DokuHTTPClient.php')
-rw-r--r--inc/HTTP/DokuHTTPClient.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/inc/HTTP/DokuHTTPClient.php b/inc/HTTP/DokuHTTPClient.php
new file mode 100644
index 000000000..b1db7e3c5
--- /dev/null
+++ b/inc/HTTP/DokuHTTPClient.php
@@ -0,0 +1,77 @@
+<?php
+
+
+namespace dokuwiki\HTTP;
+
+
+
+/**
+ * Adds DokuWiki specific configs to the HTTP client
+ *
+ * @author Andreas Goetz <cpuidle@gmx.de>
+ */
+class DokuHTTPClient extends HTTPClient {
+
+ /**
+ * Constructor.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+ public function __construct(){
+ global $conf;
+
+ // call parent constructor
+ parent::__construct();
+
+ // set some values from the config
+ $this->proxy_host = $conf['proxy']['host'];
+ $this->proxy_port = $conf['proxy']['port'];
+ $this->proxy_user = $conf['proxy']['user'];
+ $this->proxy_pass = conf_decodeString($conf['proxy']['pass']);
+ $this->proxy_ssl = $conf['proxy']['ssl'];
+ $this->proxy_except = $conf['proxy']['except'];
+
+ // allow enabling debugging via URL parameter (if debugging allowed)
+ if($conf['allowdebug']) {
+ if(
+ isset($_REQUEST['httpdebug']) ||
+ (
+ isset($_SERVER['HTTP_REFERER']) &&
+ strpos($_SERVER['HTTP_REFERER'], 'httpdebug') !== false
+ )
+ ) {
+ $this->debug = true;
+ }
+ }
+ }
+
+
+ /**
+ * Wraps an event around the parent function
+ *
+ * @triggers HTTPCLIENT_REQUEST_SEND
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+ /**
+ * @param string $url
+ * @param string|array $data the post data either as array or raw data
+ * @param string $method
+ * @return bool
+ */
+ public function sendRequest($url,$data='',$method='GET'){
+ $httpdata = array('url' => $url,
+ 'data' => $data,
+ 'method' => $method);
+ $evt = new \Doku_Event('HTTPCLIENT_REQUEST_SEND',$httpdata);
+ if($evt->advise_before()){
+ $url = $httpdata['url'];
+ $data = $httpdata['data'];
+ $method = $httpdata['method'];
+ }
+ $evt->advise_after();
+ unset($evt);
+ return parent::sendRequest($url,$data,$method);
+ }
+
+}
+