Commit
Author: Jason White [jwhite@esri.com]
Hash: 798b79ea71cc4c8048427da6a2dc70e1b7be38ea
Timestamp: Mon, 01 Apr 2019 23:22:04 +0000 (6 years ago)

+14 -14 +/-5 browse
Use scheme from X-Forwarded-Proto if available
1diff --git a/.cirrus.yml b/.cirrus.yml
2index 175605b..1a972c0 100644
3--- a/.cirrus.yml
4+++ b/.cirrus.yml
5 @@ -8,11 +8,11 @@ fmt_task:
6 # Run clippy.
7 clippy_task:
8 container:
9- image: rustlang/rust:nightly
10+ image: rust:latest
11 cargo_cache:
12 folder: $CARGO_HOME/registry
13 fingerprint_script: cat Cargo.lock
14- install_script: rustup component add clippy-preview
15+ install_script: rustup component add clippy
16 check_script: cargo clippy
17 before_cache_script: rm -rf $CARGO_HOME/registry/index
18
19 diff --git a/Cargo.lock b/Cargo.lock
20index fbeb650..f2ce20f 100644
21--- a/Cargo.lock
22+++ b/Cargo.lock
23 @@ -946,7 +946,7 @@ dependencies = [
24
25 [[package]]
26 name = "rudolfs"
27- version = "0.2.0"
28+ version = "0.2.1"
29 dependencies = [
30 "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
31 "chacha 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
32 diff --git a/src/app.rs b/src/app.rs
33index 3272de5..08c3ecd 100644
34--- a/src/app.rs
35+++ b/src/app.rs
36 @@ -421,7 +421,7 @@ fn basic_response(
37 size: object.size,
38 error: Some(lfs::ObjectError {
39 code: 404,
40- message: "not found".into(),
41+ message: "object not found".into(),
42 }),
43 authenticated: Some(true),
44 actions: None,
45 diff --git a/src/hyperext.rs b/src/hyperext.rs
46index c6cdc80..cd25498 100644
47--- a/src/hyperext.rs
48+++ b/src/hyperext.rs
49 @@ -186,25 +186,25 @@ where
50 pub trait RequestExt {
51 /// Gets the scheme based on the headers in the request.
52 ///
53- /// There's no good way to determine the scheme for HTTP/1, so we must defer
54- /// to other methods in that case (such as from a server configuration
55- /// file).
56- ///
57- /// HTTP/2 has the `:scheme` header that can tell us the scheme.
58+ /// First checks `X-Forwarded-Proto` and then falls back to the HTTP/2
59+ /// `:scheme` header.
60 fn scheme(&self) -> Option<Scheme>;
61
62 /// Gets the authority based on the headers in the request.
63 ///
64- /// First checks the HTTP/2 header `:athority` and then falls back to the
65+ /// First checks the HTTP/2 header `:authority` and then falls back to the
66 /// `Host` header.
67 fn authority(&self) -> Option<Authority>;
68 }
69
70 impl<B> RequestExt for Request<B> {
71 fn scheme(&self) -> Option<Scheme> {
72- self.headers().get(":scheme").and_then(|scheme| {
73- Scheme::from_shared(scheme.as_bytes().into()).ok()
74- })
75+ self.headers()
76+ .get("X-Forwarded-Proto")
77+ .or_else(|| self.headers().get(":scheme"))
78+ .and_then(|scheme| {
79+ Scheme::from_shared(scheme.as_bytes().into()).ok()
80+ })
81 }
82
83 fn authority(&self) -> Option<Authority> {
84 diff --git a/src/storage/mod.rs b/src/storage/mod.rs
85index c2c606c..4da3122 100644
86--- a/src/storage/mod.rs
87+++ b/src/storage/mod.rs
88 @@ -148,7 +148,7 @@ impl LFSObject {
89 pub fn split(self) -> (Self, Self) {
90 let (len, stream) = self.into_parts();
91
92- let (sender, receiver) = mpsc::channel(1);
93+ let (sender, receiver) = mpsc::channel(0);
94
95 let stream = stream.and_then(move |chunk| {
96 // TODO: Find a way to not clone the sender.