Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/pitpit/zf2 into hotfix/pr…
Browse files Browse the repository at this point in the history
…-442
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/Reader/Entry/AbstractEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
namespace Zend\Feed\Reader\Entry;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Exception;

/**
* @uses \Zend\Feed\Reader\Exception
Expand Down Expand Up @@ -219,7 +220,7 @@ public function __call($method, $args)
}
}
throw new Exception('Method: ' . $method
. 'does not exist and could not be located on a registered Extension');
. ' does not exist and could not be located on a registered Extension');
}

/**
Expand Down
34 changes: 17 additions & 17 deletions src/Reader/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ public static function import($uri, $etag = null, $lastModified = null)
$responseXml = '';
$client = self::getHttpClient();
$client->resetParameters();
$client->setHeaders('If-None-Match', null);
$client->setHeaders('If-Modified-Since', null);
$headers = new Http\Headers();
$client->setHeaders($headers);
$client->setUri($uri);
$cacheId = 'Zend_Feed_Reader_' . md5($uri);

Expand All @@ -226,17 +226,17 @@ public static function import($uri, $etag = null, $lastModified = null)
$lastModified = $cache->load($cacheId.'_lastmodified');;
}
if ($etag) {
$client->setHeaders('If-None-Match', $etag);
$headers->addHeaderLine('If-None-Match', $etag);
}
if ($lastModified) {
$client->setHeaders('If-Modified-Since', $lastModified);
$headers->addHeaderLine('If-Modified-Since', $lastModified);
}
}
$response = $client->request('GET');
if ($response->getStatus() !== 200 && $response->getStatus() !== 304) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatus());
$response = $client->send();
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 304) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatusCode());
}
if ($response->getStatus() == 304) {
if ($response->getStatusCode() == 304) {
$responseXml = $data;
} else {
$responseXml = $response->getBody();
Expand All @@ -254,17 +254,17 @@ public static function import($uri, $etag = null, $lastModified = null)
if ($data !== false) {
return self::importString($data);
}
$response = $client->request('GET');
if ($response->getStatus() !== 200) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatus());
$response = $client->send();
if ((int)$response->getStatusCode() !== 200) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatusCode());
}
$responseXml = $response->getBody();
$cache->save($responseXml, $cacheId);
return self::importString($responseXml);
} else {
$response = $client->request('GET');
if ($response->getStatus() !== 200) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatus());
$response = $client->send();
if ((int)$response->getStatusCode() !== 200) {
throw new Exception('Feed failed to load, got response code ' . $response->getStatusCode());
}
$reader = self::importString($response->getBody());
$reader->setOriginalSourceUri($uri);
Expand Down Expand Up @@ -335,9 +335,9 @@ public static function findFeedLinks($uri)
{
$client = self::getHttpClient();
$client->setUri($uri);
$response = $client->request();
if ($response->getStatus() !== 200) {
throw new Exception("Failed to access $uri, got response code " . $response->getStatus());
$response = $client->send();
if ($response->getStatusCode() !== 200) {
throw new Exception("Failed to access $uri, got response code " . $response->getStatusCode());
}
$responseHtml = $response->getBody();
$libxml_errflag = libxml_use_internal_errors(true);
Expand Down

0 comments on commit 7ca3746

Please sign in to comment.