Merge pull request #3024 from splitbrain/cookieupdate
[dokuwiki.git] / inc / HTTP / DokuHTTPClient.php
blobb1db7e3c5fd789099fc6cd76c2c1a5a83b742564
1 <?php
4 namespace dokuwiki\HTTP;
8 /**
9 * Adds DokuWiki specific configs to the HTTP client
11 * @author Andreas Goetz <cpuidle@gmx.de>
13 class DokuHTTPClient extends HTTPClient {
15 /**
16 * Constructor.
18 * @author Andreas Gohr <andi@splitbrain.org>
20 public function __construct(){
21 global $conf;
23 // call parent constructor
24 parent::__construct();
26 // set some values from the config
27 $this->proxy_host = $conf['proxy']['host'];
28 $this->proxy_port = $conf['proxy']['port'];
29 $this->proxy_user = $conf['proxy']['user'];
30 $this->proxy_pass = conf_decodeString($conf['proxy']['pass']);
31 $this->proxy_ssl = $conf['proxy']['ssl'];
32 $this->proxy_except = $conf['proxy']['except'];
34 // allow enabling debugging via URL parameter (if debugging allowed)
35 if($conf['allowdebug']) {
36 if(
37 isset($_REQUEST['httpdebug']) ||
39 isset($_SERVER['HTTP_REFERER']) &&
40 strpos($_SERVER['HTTP_REFERER'], 'httpdebug') !== false
42 ) {
43 $this->debug = true;
49 /**
50 * Wraps an event around the parent function
52 * @triggers HTTPCLIENT_REQUEST_SEND
53 * @author Andreas Gohr <andi@splitbrain.org>
55 /**
56 * @param string $url
57 * @param string|array $data the post data either as array or raw data
58 * @param string $method
59 * @return bool
61 public function sendRequest($url,$data='',$method='GET'){
62 $httpdata = array('url' => $url,
63 'data' => $data,
64 'method' => $method);
65 $evt = new \Doku_Event('HTTPCLIENT_REQUEST_SEND',$httpdata);
66 if($evt->advise_before()){
67 $url = $httpdata['url'];
68 $data = $httpdata['data'];
69 $method = $httpdata['method'];
71 $evt->advise_after();
72 unset($evt);
73 return parent::sendRequest($url,$data,$method);