mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-19 16:46:35 +00:00
Port HTTP source from hyper to reqwest
This commit is contained in:
parent
2408edf1bf
commit
f7148bd910
3 changed files with 11 additions and 12 deletions
|
@ -9,8 +9,8 @@ license = "LGPL-2.1+"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
url = "1.1"
|
url = "1.1"
|
||||||
hyper = "0.9"
|
|
||||||
bitflags = "0.7"
|
bitflags = "0.7"
|
||||||
|
reqwest = { git = "https://github.com/sdroege/reqwest.git"}
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gcc = "0.3"
|
gcc = "0.3"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
extern crate hyper;
|
extern crate reqwest;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,9 @@
|
||||||
use std::u64;
|
use std::u64;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use hyper::header::{ContentLength, ContentRange, ContentRangeSpec, Range, ByteRangeSpec,
|
use reqwest::{Client, Response};
|
||||||
|
use reqwest::header::{ContentLength, ContentRange, ContentRangeSpec, Range, ByteRangeSpec,
|
||||||
AcceptRanges, RangeUnit};
|
AcceptRanges, RangeUnit};
|
||||||
use hyper::client::Client;
|
|
||||||
use hyper::client::response::Response;
|
|
||||||
|
|
||||||
use error::*;
|
use error::*;
|
||||||
use rssource::*;
|
use rssource::*;
|
||||||
|
@ -51,7 +50,7 @@ impl HttpSrc {
|
||||||
pub fn new() -> HttpSrc {
|
pub fn new() -> HttpSrc {
|
||||||
HttpSrc {
|
HttpSrc {
|
||||||
streaming_state: StreamingState::Stopped,
|
streaming_state: StreamingState::Stopped,
|
||||||
client: Client::new(),
|
client: Client::new().unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,18 +79,18 @@ impl HttpSrc {
|
||||||
["Failed to fetch {}: {}", uri, err.to_string()]))
|
["Failed to fetch {}: {}", uri, err.to_string()]))
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if !response.status.is_success() {
|
if !response.status().is_success() {
|
||||||
return Err(error_msg!(SourceError::ReadFailed,
|
return Err(error_msg!(SourceError::ReadFailed,
|
||||||
["Failed to fetch {}: {}", uri, response.status]));
|
["Failed to fetch {}: {}", uri, response.status()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
let size = if let Some(&ContentLength(content_length)) = response.headers.get() {
|
let size = if let Some(&ContentLength(content_length)) = response.headers().get() {
|
||||||
Some(content_length + start)
|
Some(content_length + start)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let accept_byte_ranges = if let Some(&AcceptRanges(ref ranges)) = response.headers
|
let accept_byte_ranges = if let Some(&AcceptRanges(ref ranges)) = response.headers()
|
||||||
.get() {
|
.get() {
|
||||||
ranges.iter().any(|u| *u == RangeUnit::Bytes)
|
ranges.iter().any(|u| *u == RangeUnit::Bytes)
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,7 +101,7 @@ impl HttpSrc {
|
||||||
|
|
||||||
let position = if let Some(&ContentRange(ContentRangeSpec::Bytes { range: Some((range_start,
|
let position = if let Some(&ContentRange(ContentRangeSpec::Bytes { range: Some((range_start,
|
||||||
_)),
|
_)),
|
||||||
.. })) = response.headers
|
.. })) = response.headers()
|
||||||
.get() {
|
.get() {
|
||||||
range_start
|
range_start
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue