From 3b787fa52acd8f58a58ece80238abdcafddf0155 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 5 Jun 2009 12:46:03 +0200 Subject: Moved HTTPCLIENT_REQUEST_SEND event Ignore-this: 8e7c6aae103f1bced33a74a2440c2fe8 This patch moves the HTTPCLIENT_REQUEST_SEND event from HTTPClient to DokuHTTPClient. This keeps the main HTTPClient class free from any DokuWiki specific code for easier reuse elsewhere. darcs-hash:20090605104603-7ad00-8e56892a7f20b4c7010fb2f8d54ae381f984dfc2.gz --- inc/HTTPClient.php | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 0c3b4f435..e769b0c93 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -35,6 +35,29 @@ class DokuHTTPClient extends HTTPClient { $this->proxy_pass = conf_decodeString($conf['proxy']['pass']); $this->proxy_ssl = $conf['proxy']['ssl']; } + + + /** + * Wraps an event around the parent function + * + * @triggers HTTPCLIENT_REQUEST_SEND + * @author Andreas Gohr + */ + 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); + } + } /** @@ -165,19 +188,6 @@ class HTTPClient { unset($this->headers['Accept-encoding']); } - - $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); - // parse URL into bits $uri = parse_url($url); $server = $uri['host']; -- cgit v1.2.3