Update to reqwest 0.9, rand 0.6 and parking_lot 0.7

This commit is contained in:
Sebastian Dröge 2018-12-19 14:31:42 +02:00
parent f374d7fedf
commit 04955f61d7
5 changed files with 20 additions and 14 deletions

View file

@ -10,7 +10,8 @@ url = "1.1"
glib = { git = "https://github.com/gtk-rs/glib" }
gst-plugin = { path="../gst-plugin" }
gst-plugin-simple = { path="../gst-plugin-simple" }
reqwest = "0.8"
reqwest = "0.9"
hyperx = "0.13"
gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
[lib]

View file

@ -6,8 +6,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use reqwest::header::{
AcceptRanges, ByteRangeSpec, ContentLength, ContentRange, ContentRangeSpec, Range, RangeUnit,
use hyperx::header::{
AcceptRanges, ByteRangeSpec, ContentLength, ContentRange, ContentRangeSpec, Headers, Range,
RangeUnit,
};
use reqwest::{Client, Response};
use std::io::Read;
@ -68,18 +69,23 @@ impl HttpSrc {
stop: Option<u64>,
) -> Result<StreamingState, gst::ErrorMessage> {
let cat = self.cat;
let mut req = self.client.get(uri.clone());
let req = self.client.get(uri.clone());
let mut headers = Headers::new();
match (start != 0, stop) {
(false, None) => (),
(true, None) => {
req.header(Range::Bytes(vec![ByteRangeSpec::AllFrom(start)]));
headers.set(Range::Bytes(vec![ByteRangeSpec::AllFrom(start)]));
}
(_, Some(stop)) => {
req.header(Range::Bytes(vec![ByteRangeSpec::FromTo(start, stop - 1)]));
headers.set(Range::Bytes(vec![ByteRangeSpec::FromTo(start, stop - 1)]));
}
}
// Add all headers for the request here
let req = req.headers(headers.into());
gst_debug!(cat, obj: src, "Doing new request {:?}", req);
let response = try!(req.send().or_else(|err| {
@ -98,12 +104,10 @@ impl HttpSrc {
));
}
let size = response
.headers()
.get()
.map(|&ContentLength(cl)| cl + start);
let headers = Headers::from(response.headers());
let size = headers.get().map(|&ContentLength(cl)| cl + start);
let accept_byte_ranges = if let Some(&AcceptRanges(ref ranges)) = response.headers().get() {
let accept_byte_ranges = if let Some(&AcceptRanges(ref ranges)) = headers.get() {
ranges.iter().any(|u| *u == RangeUnit::Bytes)
} else {
false
@ -114,7 +118,7 @@ impl HttpSrc {
let position = if let Some(&ContentRange(ContentRangeSpec::Bytes {
range: Some((range_start, _)),
..
})) = response.headers().get()
})) = headers.get()
{
range_start
} else {

View file

@ -14,6 +14,7 @@ extern crate gst_plugin;
extern crate gst_plugin_simple;
#[macro_use]
extern crate gstreamer as gst;
extern crate hyperx;
extern crate reqwest;
extern crate url;

View file

@ -22,7 +22,7 @@ tokio-current-thread = "0.1"
futures = "0.1"
lazy_static = "1.0"
either = "1.0"
rand = "0.5"
rand = "0.6"
net2 = "0.2"
[target.'cfg(windows)'.dependencies]

View file

@ -10,7 +10,7 @@ gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", fea
gstreamer-video = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gtk = { git = "https://github.com/gtk-rs/gtk", features = ["v3_6"], optional = true }
gio = { git = "https://github.com/gtk-rs/gio", optional = true }
parking_lot = "0.6"
parking_lot = "0.7"
[dev-dependencies]
either = "1.0"