Check more http status codes when parsing feeds.
This commit is contained in:
parent
81b1ec810c
commit
345d4b3865
@ -630,6 +630,7 @@ impl<'a> Source {
|
|||||||
// TODO: Refactor into TryInto once it lands on stable.
|
// TODO: Refactor into TryInto once it lands on stable.
|
||||||
pub fn into_feed(mut self, ignore_etags: bool) -> Result<Feed> {
|
pub fn into_feed(mut self, ignore_etags: bool) -> Result<Feed> {
|
||||||
use reqwest::header::{EntityTag, Headers, HttpDate, IfModifiedSince, IfNoneMatch};
|
use reqwest::header::{EntityTag, Headers, HttpDate, IfModifiedSince, IfNoneMatch};
|
||||||
|
use reqwest::StatusCode;
|
||||||
|
|
||||||
let mut headers = Headers::new();
|
let mut headers = Headers::new();
|
||||||
|
|
||||||
@ -655,12 +656,26 @@ impl<'a> Source {
|
|||||||
self.update_etag(&req)?;
|
self.update_etag(&req)?;
|
||||||
|
|
||||||
// TODO match on more stuff
|
// TODO match on more stuff
|
||||||
// 301: Permanent redirect of the url
|
// 301: Moved Permanently
|
||||||
// 302: Temporary redirect of the url
|
|
||||||
// 304: Up to date Feed, checked with the Etag
|
// 304: Up to date Feed, checked with the Etag
|
||||||
|
// 307: Temporary redirect of the url
|
||||||
|
// 308: Permanent redirect of the url
|
||||||
|
// 401: Unathorized
|
||||||
|
// 403: Forbidden
|
||||||
|
// 408: Timeout
|
||||||
// 410: Feed deleted
|
// 410: Feed deleted
|
||||||
match req.status() {
|
match req.status() {
|
||||||
reqwest::StatusCode::NotModified => bail!("304, skipping.."),
|
StatusCode::NotModified => bail!("304: skipping.."),
|
||||||
|
StatusCode::TemporaryRedirect => debug!("307: Temporary Redirect."),
|
||||||
|
// TODO: Change the source uri to the new one
|
||||||
|
StatusCode::MovedPermanently | StatusCode::PermanentRedirect => {
|
||||||
|
warn!("Feed was moved permanently.")
|
||||||
|
}
|
||||||
|
StatusCode::Unauthorized => bail!("401: Unauthorized."),
|
||||||
|
StatusCode::Forbidden => bail!("403: Forbidden."),
|
||||||
|
StatusCode::NotFound => bail!("404: Not found."),
|
||||||
|
StatusCode::RequestTimeout => bail!("408: Request Timeout."),
|
||||||
|
StatusCode::Gone => bail!("410: Feed was deleted."),
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user