mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-13 22:01:19 +00:00
Some more error handling in the HTTP source
This commit is contained in:
parent
b2b8332043
commit
2298fc3353
1 changed files with 17 additions and 10 deletions
|
@ -84,12 +84,13 @@ impl Source for HttpSrc {
|
||||||
match self.url {
|
match self.url {
|
||||||
None => return false,
|
None => return false,
|
||||||
Some(ref url) => {
|
Some(ref url) => {
|
||||||
let response = self.client.get(url.clone()).send().unwrap();
|
match self.client.get(url.clone()).send() {
|
||||||
|
Ok(response) => {
|
||||||
if response.status.is_success() {
|
if response.status.is_success() {
|
||||||
match response.headers.get::<ContentLength>() {
|
self.size = match response.headers.get::<ContentLength>() {
|
||||||
Some(&ContentLength(size)) => self.size = size,
|
Some(&ContentLength(size)) => size,
|
||||||
_ => self.size = u64::MAX
|
_ => u64::MAX
|
||||||
}
|
};
|
||||||
self.response = Some(response);
|
self.response = Some(response);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -97,6 +98,12 @@ impl Source for HttpSrc {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Err(err) => {
|
||||||
|
println_err!("Failed to fetch {}: {}", url, err.to_string());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue