Skip to content
Snippets Groups Projects
Commit ec79c838 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

Feedfetcher/HTTPClient fix

This fixes a typo which made the new Feedparser not use our own HTTPClient.
It also enhances the get() method of HTTPClient to optionally cope better
with bad HTTP responses:

Some servers return a body with a "304 Not Modified" status which violates
RFC 2616 but is usually accepted by common browsers. Setting the $sloppy304
parameter will return the response body. This fixes problems with feeds
from feedblendr.com

darcs-hash:20060429155805-7ad00-33a1c3142f241bf7747e8f679237cb6e8f1564ef.gz
parent d88b5f04
No related branches found
No related tags found
No related merge requests found
...@@ -25,9 +25,11 @@ class FeedParser extends SimplePie { ...@@ -25,9 +25,11 @@ class FeedParser extends SimplePie {
/** /**
* Fetch an URL using our own HTTPClient * Fetch an URL using our own HTTPClient
*
* Overrides SimplePie's own method
*/ */
function getFile($url){ function get_file($url){
$http = new DokuHTTPClient(); $http = new DokuHTTPClient();
return $http->get($url); return $http->get($url,true);
} }
} }
...@@ -111,10 +111,13 @@ class HTTPClient { ...@@ -111,10 +111,13 @@ class HTTPClient {
* *
* Returns the wanted page or false on an error; * Returns the wanted page or false on an error;
* *
* @param string $url The URL to fetch
* @param bool $sloppy304 Return body on 304 not modified
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
*/ */
function get($url){ function get($url,$sloppy304=false){
if(!$this->sendRequest($url)) return false; if(!$this->sendRequest($url)) return false;
if($this->status == 304 && $sloppy304) return $this->resp_body;
if($this->status != 200) return false; if($this->status != 200) return false;
return $this->resp_body; return $this->resp_body;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment