Update picofeed to handle HTTP 303 redirects

This commit is contained in:
Frederic Guillot 2015-10-23 18:06:09 -04:00
parent b5a8430926
commit 9949099000
8 changed files with 36 additions and 11 deletions

View File

@ -14,7 +14,7 @@
"fguillot/simple-validator": "v1.0.0",
"fguillot/json-rpc": "v1.0.2",
"fguillot/picodb": "v1.0.2",
"fguillot/picofeed": "v0.1.14"
"fguillot/picofeed": "v0.1.15"
},
"require-dev": {
"phpunit/phpunit": "4.8.3",

View File

@ -116,17 +116,17 @@
},
{
"name": "fguillot/picofeed",
"version": "v0.1.14",
"version_normalized": "0.1.14.0",
"version": "v0.1.15",
"version_normalized": "0.1.15.0",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoFeed.git",
"reference": "4cff44c2b67888ab4d5bc9ce57b5777e15818efc"
"reference": "ee91bcfd4be93d38ae5f870723c652a9d795c75f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/4cff44c2b67888ab4d5bc9ce57b5777e15818efc",
"reference": "4cff44c2b67888ab4d5bc9ce57b5777e15818efc",
"url": "https://api.github.com/repos/fguillot/picoFeed/zipball/ee91bcfd4be93d38ae5f870723c652a9d795c75f",
"reference": "ee91bcfd4be93d38ae5f870723c652a9d795c75f",
"shasum": ""
},
"require": {
@ -140,7 +140,7 @@
"suggest": {
"ext-curl": "PicoFeed will use cURL if present"
},
"time": "2015-10-21 23:38:45",
"time": "2015-10-23 21:59:31",
"bin": [
"picofeed"
],

View File

@ -653,4 +653,16 @@ abstract class Client
return $this;
}
/**
* Return true if the HTTP status code is a redirection
*
* @access protected
* @param integer $code
* @return boolean
*/
public function isRedirection($code)
{
return $code == 301 || $code == 302 || $code == 303 || $code == 307;
}
}

View File

@ -295,7 +295,7 @@ class Curl extends Client
list($status, $headers) = HttpHeaders::parse(explode("\n", $this->response_headers[$this->response_headers_count - 1]));
if ($follow_location && ($status == 301 || $status == 302)) {
if ($follow_location && $this->isRedirection($status)) {
return $this->handleRedirection($headers['Location']);
}
@ -332,7 +332,7 @@ class Curl extends Client
$result = $this->doRequest(false);
if ($result['status'] == 301 || $result['status'] == 302) {
if ($this->isRedirection($result['status'])) {
$this->url = Url::resolve($result['headers']['Location'], $this->url);
$this->body = '';
$this->body_length = 0;

View File

@ -11,7 +11,7 @@ return array(
'//*[@id="linker_widget"]',
'//*[@class="credit"]',
'//div[@data-js="slideCount"]',
'//span[@class="visually-hidden"]',
'//*[contains(@class="visually-hidden")]',
'//*[@data-slide-number="_endslate"]',
'//*[@id="related"]',
'//*[contains(@class, "bio")]',

View File

@ -5,7 +5,7 @@ return array(
'%.*%' => array(
'test_url' => 'http://www.networkworld.com/article/2986764/smartphones/samsung-tried-to-troll-apple-fans-waiting-in-line-for-the-iphone-6s.html#tk.rss_all',
'body' => array(
'//figure/img',
'//figure/img[@class="hero-img"]',
'//section[@class="deck"]',
'//div[@itemprop="articleBody"]',
),

View File

@ -0,0 +1,12 @@
<?php
return array(
'grabber' => array(
'%.*%' => array(
'test_url' => 'http://opensource.com/life/15/10/how-internet-things-will-change-way-we-think',
'body' => array(
'//img[@class="image-full-size"]',
'//div[contains(@class="field-type-text-with-summary")]',
),
)
)
);

View File

@ -13,6 +13,7 @@ return array(
'//script',
'//div[contains(@class,"sharedaddy")]',
'//div[@class="post-send-off"]',
'//div[contains(@class,"inner-related-article")]',
),
),
),