Upgrade to hyper 0.12

This commit is contained in:
Paolo Barbolini 2020-09-29 23:03:55 +02:00
parent 54c05c20bf
commit c6b3fb46e8
17 changed files with 377 additions and 390 deletions

411
Cargo.lock generated
View file

@ -22,33 +22,17 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
name = "badge" name = "badge"
version = "0.2.0" version = "0.2.0"
dependencies = [ dependencies = [
"base64 0.12.3", "base64",
"once_cell", "once_cell",
"rusttype", "rusttype",
] ]
[[package]]
name = "base64"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643"
dependencies = [
"byteorder",
"safemem",
]
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.12.3" version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "bitflags"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.2.1"
@ -95,6 +79,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"either",
"iovec", "iovec",
] ]
@ -154,14 +139,14 @@ version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
dependencies = [ dependencies = [
"bitflags 1.2.1", "bitflags",
] ]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.2.3" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25bfd746d203017f7d5cbd31ee5d8e17f94b6521c7af77ece6c9e4b2d4b16c67" checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -169,12 +154,9 @@ dependencies = [
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.2.3" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "065a5d7ffdcbc8fa145d6f0746f3555025b9097a9e9cda59f7467abae670c78d" checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "crates-index" name = "crates-index"
@ -218,7 +200,7 @@ dependencies = [
"autocfg", "autocfg",
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
"lazy_static 1.4.0", "lazy_static",
"maybe-uninit", "maybe-uninit",
"memoffset", "memoffset",
"scopeguard", "scopeguard",
@ -243,7 +225,7 @@ checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if", "cfg-if",
"lazy_static 1.4.0", "lazy_static",
] ]
[[package]] [[package]]
@ -275,6 +257,12 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]] [[package]]
name = "fake-simd" name = "fake-simd"
version = "0.1.2" version = "0.1.2"
@ -302,19 +290,13 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]] [[package]]
name = "fuchsia-zircon" name = "fuchsia-zircon"
version = "0.3.3" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
dependencies = [ dependencies = [
"bitflags 1.2.1", "bitflags",
"fuchsia-zircon-sys", "fuchsia-zircon-sys",
] ]
@ -349,16 +331,27 @@ dependencies = [
"typenum", "typenum",
] ]
[[package]]
name = "getrandom"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
dependencies = [
"cfg-if",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]] [[package]]
name = "git2" name = "git2"
version = "0.13.11" version = "0.13.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e094214efbc7fdbbdee952147e493b00e99a4e52817492277e98967ae918165" checksum = "1e094214efbc7fdbbdee952147e493b00e99a4e52817492277e98967ae918165"
dependencies = [ dependencies = [
"bitflags 1.2.1", "bitflags",
"libc", "libc",
"libgit2-sys", "libgit2-sys",
"log 0.4.11", "log",
"openssl-probe", "openssl-probe",
"openssl-sys", "openssl-sys",
"url", "url",
@ -370,6 +363,24 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "h2"
version = "0.1.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462"
dependencies = [
"byteorder",
"bytes",
"fnv",
"futures",
"http",
"indexmap",
"log",
"slab",
"string",
"tokio-io",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.9.1" version = "0.9.1"
@ -403,6 +414,29 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "http"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0"
dependencies = [
"bytes",
"fnv",
"itoa",
]
[[package]]
name = "http-body"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d"
dependencies = [
"bytes",
"futures",
"http",
"tokio-buf",
]
[[package]] [[package]]
name = "httparse" name = "httparse"
version = "1.3.4" version = "1.3.4"
@ -411,44 +445,45 @@ checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.11.27" version = "0.12.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34a590ca09d341e94cddf8e5af0bbccde205d5fbc2fa3c09dd67c7f85cea59d7" checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6"
dependencies = [ dependencies = [
"base64 0.9.3",
"bytes", "bytes",
"futures", "futures",
"futures-cpupool", "futures-cpupool",
"h2",
"http",
"http-body",
"httparse", "httparse",
"iovec", "iovec",
"language-tags", "itoa",
"log 0.4.11", "log",
"mime",
"net2", "net2",
"percent-encoding 1.0.1", "rustc_version",
"relay",
"time", "time",
"tokio-core", "tokio",
"tokio-buf",
"tokio-executor",
"tokio-io", "tokio-io",
"tokio-proto", "tokio-reactor",
"tokio-service", "tokio-tcp",
"unicase", "tokio-threadpool",
"tokio-timer",
"want", "want",
] ]
[[package]] [[package]]
name = "hyper-tls" name = "hyper-tls"
version = "0.1.4" version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb1bd5e518d3065840ab315dbbf44e4420e5f7d80e2cb93fa6ffffc50522378" checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f"
dependencies = [ dependencies = [
"bytes",
"futures", "futures",
"hyper", "hyper",
"native-tls", "native-tls",
"tokio-core",
"tokio-io", "tokio-io",
"tokio-service",
"tokio-tls",
] ]
[[package]] [[package]]
@ -507,18 +542,6 @@ dependencies = [
"winapi-build", "winapi-build",
] ]
[[package]]
name = "language-tags"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
[[package]]
name = "lazy_static"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -586,15 +609,6 @@ dependencies = [
"scopeguard", "scopeguard",
] ]
[[package]]
name = "log"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
dependencies = [
"log 0.4.11",
]
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.11" version = "0.4.11"
@ -667,12 +681,6 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "mime"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.6.22" version = "0.6.22"
@ -685,10 +693,10 @@ dependencies = [
"iovec", "iovec",
"kernel32-sys", "kernel32-sys",
"libc", "libc",
"log 0.4.11", "log",
"miow", "miow",
"net2", "net2",
"slab 0.4.2", "slab",
"winapi 0.2.8", "winapi 0.2.8",
] ]
@ -717,17 +725,20 @@ dependencies = [
[[package]] [[package]]
name = "native-tls" name = "native-tls"
version = "0.1.5" version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f74dbadc8b43df7864539cedb7bc91345e532fdd913cfdc23ad94f4d2d40fbc0" checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d"
dependencies = [ dependencies = [
"lazy_static 0.2.11", "lazy_static",
"libc", "libc",
"log",
"openssl", "openssl",
"openssl-probe",
"openssl-sys",
"schannel", "schannel",
"security-framework", "security-framework",
"security-framework-sys", "security-framework-sys",
"tempdir", "tempfile",
] ]
[[package]] [[package]]
@ -784,13 +795,14 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]] [[package]]
name = "openssl" name = "openssl"
version = "0.9.24" version = "0.10.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985" checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4"
dependencies = [ dependencies = [
"bitflags 0.9.1", "bitflags",
"cfg-if",
"foreign-types", "foreign-types",
"lazy_static 1.4.0", "lazy_static",
"libc", "libc",
"openssl-sys", "openssl-sys",
] ]
@ -845,16 +857,10 @@ dependencies = [
"libc", "libc",
"redox_syscall", "redox_syscall",
"rustc_version", "rustc_version",
"smallvec 0.6.13", "smallvec",
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "percent-encoding"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.1.0"
@ -919,6 +925,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "ppv-lite86"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.23" version = "1.0.23"
@ -939,49 +951,43 @@ dependencies = [
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.3.23" version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [ dependencies = [
"getrandom",
"libc", "libc",
"rand 0.4.6", "rand_chacha",
"rand_core",
"rand_hc",
] ]
[[package]] [[package]]
name = "rand" name = "rand_chacha"
version = "0.4.6" version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [ dependencies = [
"fuchsia-cprng", "ppv-lite86",
"libc", "rand_core",
"rand_core 0.3.1",
"rdrand",
"winapi 0.3.9",
] ]
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.3.1" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [ dependencies = [
"rand_core 0.4.2", "getrandom",
] ]
[[package]] [[package]]
name = "rand_core" name = "rand_hc"
version = "0.4.2" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [ dependencies = [
"rand_core 0.3.1", "rand_core",
] ]
[[package]] [[package]]
@ -999,15 +1005,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "relay"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a"
dependencies = [
"futures",
]
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
version = "0.5.3" version = "0.5.3"
@ -1068,12 +1065,6 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "safemem"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
[[package]] [[package]]
name = "sass-rs" name = "sass-rs"
version = "0.2.2" version = "0.2.2"
@ -1102,7 +1093,7 @@ version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
dependencies = [ dependencies = [
"lazy_static 1.4.0", "lazy_static",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -1120,10 +1111,11 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "0.1.16" version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa44ee9c54ce5eecc9de7d5acbad112ee58755239381f687e564004ba4a2332" checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535"
dependencies = [ dependencies = [
"bitflags",
"core-foundation", "core-foundation",
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -1132,9 +1124,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework-sys" name = "security-framework-sys"
version = "0.1.16" version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5421621e836278a0b139268f36eee0dc7e389b784dc3f79d8f11aabadf41bead" checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -1255,12 +1247,6 @@ dependencies = [
"try_future", "try_future",
] ]
[[package]]
name = "slab"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23"
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.2" version = "0.4.2"
@ -1285,12 +1271,6 @@ dependencies = [
"slog", "slog",
] ]
[[package]]
name = "smallvec"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "0.6.13" version = "0.6.13"
@ -1309,6 +1289,15 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "string"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d"
dependencies = [
"bytes",
]
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.42" version = "1.0.42"
@ -1321,19 +1310,17 @@ dependencies = [
] ]
[[package]] [[package]]
name = "take" name = "tempfile"
version = "0.1.0" version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
[[package]]
name = "tempdir"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
dependencies = [ dependencies = [
"rand 0.4.6", "cfg-if",
"libc",
"rand",
"redox_syscall",
"remove_dir_all", "remove_dir_all",
"winapi 0.3.9",
] ]
[[package]] [[package]]
@ -1363,7 +1350,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [ dependencies = [
"libc", "libc",
"wasi", "wasi 0.10.0+wasi-snapshot-preview1",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -1397,6 +1384,17 @@ dependencies = [
"tokio-uds", "tokio-uds",
] ]
[[package]]
name = "tokio-buf"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46"
dependencies = [
"bytes",
"either",
"futures",
]
[[package]] [[package]]
name = "tokio-codec" name = "tokio-codec"
version = "0.1.2" version = "0.1.2"
@ -1417,7 +1415,7 @@ dependencies = [
"bytes", "bytes",
"futures", "futures",
"iovec", "iovec",
"log 0.4.11", "log",
"mio", "mio",
"scoped-tls", "scoped-tls",
"tokio", "tokio",
@ -1466,25 +1464,7 @@ checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures", "futures",
"log 0.4.11", "log",
]
[[package]]
name = "tokio-proto"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fbb47ae81353c63c487030659494b295f6cb6576242f907f203473b191b0389"
dependencies = [
"futures",
"log 0.3.9",
"net2",
"rand 0.3.23",
"slab 0.3.0",
"smallvec 0.2.1",
"take",
"tokio-core",
"tokio-io",
"tokio-service",
] ]
[[package]] [[package]]
@ -1495,12 +1475,12 @@ checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351"
dependencies = [ dependencies = [
"crossbeam-utils", "crossbeam-utils",
"futures", "futures",
"lazy_static 1.4.0", "lazy_static",
"log 0.4.11", "log",
"mio", "mio",
"num_cpus", "num_cpus",
"parking_lot", "parking_lot",
"slab 0.4.2", "slab",
"tokio-executor", "tokio-executor",
"tokio-io", "tokio-io",
"tokio-sync", "tokio-sync",
@ -1549,10 +1529,10 @@ dependencies = [
"crossbeam-queue", "crossbeam-queue",
"crossbeam-utils", "crossbeam-utils",
"futures", "futures",
"lazy_static 1.4.0", "lazy_static",
"log 0.4.11", "log",
"num_cpus", "num_cpus",
"slab 0.4.2", "slab",
"tokio-executor", "tokio-executor",
] ]
@ -1564,22 +1544,10 @@ checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296"
dependencies = [ dependencies = [
"crossbeam-utils", "crossbeam-utils",
"futures", "futures",
"slab 0.4.2", "slab",
"tokio-executor", "tokio-executor",
] ]
[[package]]
name = "tokio-tls"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "772f4b04e560117fe3b0a53e490c16ddc8ba6ec437015d91fa385564996ed913"
dependencies = [
"futures",
"native-tls",
"tokio-core",
"tokio-io",
]
[[package]] [[package]]
name = "tokio-udp" name = "tokio-udp"
version = "0.1.6" version = "0.1.6"
@ -1588,7 +1556,7 @@ checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures", "futures",
"log 0.4.11", "log",
"mio", "mio",
"tokio-codec", "tokio-codec",
"tokio-io", "tokio-io",
@ -1605,7 +1573,7 @@ dependencies = [
"futures", "futures",
"iovec", "iovec",
"libc", "libc",
"log 0.4.11", "log",
"mio", "mio",
"mio-uds", "mio-uds",
"tokio-codec", "tokio-codec",
@ -1624,9 +1592,9 @@ dependencies = [
[[package]] [[package]]
name = "try-lock" name = "try-lock"
version = "0.1.0" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642"
[[package]] [[package]]
name = "try_future" name = "try_future"
@ -1655,15 +1623,6 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check",
]
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.4" version = "0.3.4"
@ -1696,7 +1655,7 @@ checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb"
dependencies = [ dependencies = [
"idna", "idna",
"matches", "matches",
"percent-encoding 2.1.0", "percent-encoding",
] ]
[[package]] [[package]]
@ -1705,23 +1664,23 @@ version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c"
[[package]]
name = "version_check"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
[[package]] [[package]]
name = "want" name = "want"
version = "0.0.4" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a05d9d966753fa4b5c8db73fcab5eed4549cfe0e1e4e66911e5564a0085c35d1" checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230"
dependencies = [ dependencies = [
"futures", "futures",
"log 0.4.11", "log",
"try-lock", "try-lock",
] ]
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.10.0+wasi-snapshot-preview1" version = "0.10.0+wasi-snapshot-preview1"

View file

@ -17,8 +17,8 @@ anyhow = "1"
cadence = "0.13" cadence = "0.13"
derive_more = "0.99" derive_more = "0.99"
futures = "0.1" futures = "0.1"
hyper = "0.11" hyper = "0.12"
hyper-tls = "0.1" hyper-tls = "0.3"
indexmap = { version = "1", features = ["serde-1"] } indexmap = { version = "1", features = ["serde-1"] }
lru-cache = "0.1" lru-cache = "0.1"
maud = "0.22" maud = "0.22"

View file

@ -8,7 +8,7 @@ use super::super::machines::analyzer::DependencyAnalyzer;
use super::super::Engine; use super::super::Engine;
pub struct AnalyzeDependenciesFuture { pub struct AnalyzeDependenciesFuture {
inner: Box<dyn Future<Item = AnalyzedDependencies, Error = Error>>, inner: Box<dyn Future<Item = AnalyzedDependencies, Error = Error> + Send>,
} }
impl AnalyzeDependenciesFuture { impl AnalyzeDependenciesFuture {

View file

@ -15,12 +15,13 @@ pub struct CrawlManifestFuture {
repo_path: RepoPath, repo_path: RepoPath,
engine: Engine, engine: Engine,
crawler: ManifestCrawler, crawler: ManifestCrawler,
futures: FuturesOrdered<Box<dyn Future<Item = (RelativePathBuf, String), Error = Error>>>, futures:
FuturesOrdered<Box<dyn Future<Item = (RelativePathBuf, String), Error = Error> + Send>>,
} }
impl CrawlManifestFuture { impl CrawlManifestFuture {
pub fn new(engine: &Engine, repo_path: RepoPath, entry_point: RelativePathBuf) -> Self { pub fn new(engine: &Engine, repo_path: RepoPath, entry_point: RelativePathBuf) -> Self {
let future: Box<dyn Future<Item = _, Error = _>> = Box::new( let future: Box<dyn Future<Item = _, Error = _> + Send> = Box::new(
engine engine
.retrieve_manifest_at_path(&repo_path, &entry_point) .retrieve_manifest_at_path(&repo_path, &entry_point)
.map(move |contents| (entry_point, contents)), .map(move |contents| (entry_point, contents)),
@ -52,7 +53,7 @@ impl Future for CrawlManifestFuture {
Some((path, raw_manifest)) => { Some((path, raw_manifest)) => {
let output = self.crawler.step(path, raw_manifest)?; let output = self.crawler.step(path, raw_manifest)?;
for path in output.paths_of_interest.into_iter() { for path in output.paths_of_interest.into_iter() {
let future: Box<dyn Future<Item = _, Error = _>> = Box::new( let future: Box<dyn Future<Item = _, Error = _> + Send> = Box::new(
self.engine self.engine
.retrieve_manifest_at_path(&self.repo_path, &path) .retrieve_manifest_at_path(&self.repo_path, &path)
.map(move |contents| (path, contents)), .map(move |contents| (path, contents)),

View file

@ -2,13 +2,13 @@ use std::collections::HashSet;
use std::sync::Arc; use std::sync::Arc;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use anyhow::{anyhow, ensure, Error};
use cadence::prelude::*; use cadence::prelude::*;
use cadence::{MetricSink, NopMetricSink, StatsdClient}; use cadence::{MetricSink, NopMetricSink, StatsdClient};
use anyhow::{anyhow, ensure, Error};
use futures::future::join_all; use futures::future::join_all;
use futures::{future, Future}; use futures::{future, Future};
use hyper::client::HttpConnector; use hyper::client::{HttpConnector, ResponseFuture};
use hyper::Client; use hyper::{Body, Client, Request, Response};
use hyper_tls::HttpsConnector; use hyper_tls::HttpsConnector;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use relative_path::{RelativePath, RelativePathBuf}; use relative_path::{RelativePath, RelativePathBuf};
@ -35,30 +35,56 @@ use self::fut::CrawlManifestFuture;
type HttpClient = Client<HttpsConnector<HttpConnector>>; type HttpClient = Client<HttpsConnector<HttpConnector>>;
// workaround for hyper 0.12 not implementing Service for Client
#[derive(Debug, Clone)]
struct ServiceHttpClient(HttpClient);
impl Service for ServiceHttpClient {
type Request = Request<Body>;
type Response = Response<Body>;
type Error = hyper::Error;
type Future = ResponseFuture;
fn call(&self, req: Self::Request) -> Self::Future {
self.0.request(req)
}
}
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Engine { pub struct Engine {
client: HttpClient, client: HttpClient,
logger: Logger, logger: Logger,
metrics: StatsdClient, metrics: StatsdClient,
query_crate: Arc<Cache<QueryCrate<ServiceHttpClient>>>,
query_crate: Arc<Cache<QueryCrate<HttpClient>>>, get_popular_crates: Arc<Cache<GetPopularCrates<ServiceHttpClient>>>,
get_popular_crates: Arc<Cache<GetPopularCrates<HttpClient>>>, get_popular_repos: Arc<Cache<GetPopularRepos<ServiceHttpClient>>>,
get_popular_repos: Arc<Cache<GetPopularRepos<HttpClient>>>, retrieve_file_at_path: Arc<RetrieveFileAtPath<ServiceHttpClient>>,
retrieve_file_at_path: Arc<RetrieveFileAtPath<HttpClient>>, fetch_advisory_db: Arc<Cache<FetchAdvisoryDatabase<ServiceHttpClient>>>,
fetch_advisory_db: Arc<Cache<FetchAdvisoryDatabase<HttpClient>>>,
} }
impl Engine { impl Engine {
pub fn new(client: Client<HttpsConnector<HttpConnector>>, logger: Logger) -> Engine { pub fn new(client: Client<HttpsConnector<HttpConnector>>, logger: Logger) -> Engine {
let metrics = StatsdClient::from_sink("engine", NopMetricSink); let metrics = StatsdClient::from_sink("engine", NopMetricSink);
let query_crate = Cache::new(QueryCrate(client.clone()), Duration::from_secs(300), 500); let service_client = ServiceHttpClient(client.clone());
let get_popular_crates =
Cache::new(GetPopularCrates(client.clone()), Duration::from_secs(10), 1); let query_crate = Cache::new(
let get_popular_repos = QueryCrate(service_client.clone()),
Cache::new(GetPopularRepos(client.clone()), Duration::from_secs(10), 1); Duration::from_secs(300),
500,
);
let get_popular_crates = Cache::new(
GetPopularCrates(service_client.clone()),
Duration::from_secs(10),
1,
);
let get_popular_repos = Cache::new(
GetPopularRepos(service_client.clone()),
Duration::from_secs(10),
1,
);
let fetch_advisory_db = Cache::new( let fetch_advisory_db = Cache::new(
FetchAdvisoryDatabase(client.clone()), FetchAdvisoryDatabase(service_client.clone()),
Duration::from_secs(300), Duration::from_secs(300),
1, 1,
); );
@ -67,11 +93,10 @@ impl Engine {
client: client.clone(), client: client.clone(),
logger, logger,
metrics, metrics,
query_crate: Arc::new(query_crate), query_crate: Arc::new(query_crate),
get_popular_crates: Arc::new(get_popular_crates), get_popular_crates: Arc::new(get_popular_crates),
get_popular_repos: Arc::new(get_popular_repos), get_popular_repos: Arc::new(get_popular_repos),
retrieve_file_at_path: Arc::new(RetrieveFileAtPath(client)), retrieve_file_at_path: Arc::new(RetrieveFileAtPath(service_client)),
fetch_advisory_db: Arc::new(fetch_advisory_db), fetch_advisory_db: Arc::new(fetch_advisory_db),
} }
} }
@ -107,7 +132,7 @@ impl AnalyzeDependenciesOutcome {
} }
impl Engine { impl Engine {
pub fn get_popular_repos(&self) -> impl Future<Item = Vec<Repository>, Error = Error> { pub fn get_popular_repos(&self) -> impl Future<Item = Vec<Repository>, Error = Error> + Send {
self.get_popular_repos.call(()).from_err().map(|repos| { self.get_popular_repos.call(()).from_err().map(|repos| {
repos repos
.iter() .iter()
@ -117,7 +142,7 @@ impl Engine {
}) })
} }
pub fn get_popular_crates(&self) -> impl Future<Item = Vec<CratePath>, Error = Error> { pub fn get_popular_crates(&self) -> impl Future<Item = Vec<CratePath>, Error = Error> + Send {
self.get_popular_crates self.get_popular_crates
.call(()) .call(())
.from_err() .from_err()
@ -127,7 +152,7 @@ impl Engine {
pub fn analyze_repo_dependencies( pub fn analyze_repo_dependencies(
&self, &self,
repo_path: RepoPath, repo_path: RepoPath,
) -> impl Future<Item = AnalyzeDependenciesOutcome, Error = Error> { ) -> impl Future<Item = AnalyzeDependenciesOutcome, Error = Error> + Send {
let start = Instant::now(); let start = Instant::now();
let entry_point = RelativePath::new("/").to_relative_path_buf(); let entry_point = RelativePath::new("/").to_relative_path_buf();
@ -164,7 +189,7 @@ impl Engine {
pub fn analyze_crate_dependencies( pub fn analyze_crate_dependencies(
&self, &self,
crate_path: CratePath, crate_path: CratePath,
) -> impl Future<Item = AnalyzeDependenciesOutcome, Error = Error> { ) -> impl Future<Item = AnalyzeDependenciesOutcome, Error = Error> + Send {
let start = Instant::now(); let start = Instant::now();
let query_future = self.query_crate.call(crate_path.name.clone()).from_err(); let query_future = self.query_crate.call(crate_path.name.clone()).from_err();
@ -199,7 +224,7 @@ impl Engine {
&self, &self,
name: CrateName, name: CrateName,
req: VersionReq, req: VersionReq,
) -> impl Future<Item = Option<CrateRelease>, Error = Error> { ) -> impl Future<Item = Option<CrateRelease>, Error = Error> + Send {
self.query_crate self.query_crate
.call(name) .call(name)
.from_err() .from_err()
@ -231,13 +256,13 @@ impl Engine {
&self, &self,
repo_path: &RepoPath, repo_path: &RepoPath,
path: &RelativePathBuf, path: &RelativePathBuf,
) -> impl Future<Item = String, Error = Error> { ) -> impl Future<Item = String, Error = Error> + Send {
let manifest_path = path.join(RelativePath::new("Cargo.toml")); let manifest_path = path.join(RelativePath::new("Cargo.toml"));
self.retrieve_file_at_path self.retrieve_file_at_path
.call((repo_path.clone(), manifest_path)) .call((repo_path.clone(), manifest_path))
} }
fn fetch_advisory_db(&self) -> impl Future<Item = Arc<Database>, Error = Error> { fn fetch_advisory_db(&self) -> impl Future<Item = Arc<Database>, Error = Error> + Send {
self.fetch_advisory_db self.fetch_advisory_db
.call(()) .call(())
.from_err() .from_err()

View file

@ -2,7 +2,7 @@ use std::str;
use anyhow::{anyhow, ensure, Error}; use anyhow::{anyhow, ensure, Error};
use futures::{future, Future, IntoFuture, Stream}; use futures::{future, Future, IntoFuture, Stream};
use hyper::{Error as HyperError, Method, Request, Response, Uri}; use hyper::{Body, Error as HyperError, Method, Request, Response, Uri};
use semver::{Version, VersionReq}; use semver::{Version, VersionReq};
use serde::Deserialize; use serde::Deserialize;
use tokio_service::Service; use tokio_service::Service;
@ -74,13 +74,15 @@ pub struct QueryCrate<S>(pub S);
impl<S> Service for QueryCrate<S> impl<S> Service for QueryCrate<S>
where where
S: Service<Request = Request, Response = Response, Error = HyperError> + Clone + 'static, S: Service<Request = Request<Body>, Response = Response<Body>, Error = HyperError>
S::Future: 'static, + Clone
+ 'static,
S::Future: Send + 'static,
{ {
type Request = CrateName; type Request = CrateName;
type Response = QueryCrateResponse; type Response = QueryCrateResponse;
type Error = Error; type Error = Error;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>; type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error> + Send>;
fn call(&self, crate_name: CrateName) -> Self::Future { fn call(&self, crate_name: CrateName) -> Self::Future {
let lower_name = crate_name.as_ref().to_lowercase(); let lower_name = crate_name.as_ref().to_lowercase();
@ -95,7 +97,7 @@ where
let uri = let uri =
try_future_box!(format!("{}/master/{}", CRATES_INDEX_BASE_URI, path).parse::<Uri>()); try_future_box!(format!("{}/master/{}", CRATES_INDEX_BASE_URI, path).parse::<Uri>());
let request = Request::new(Method::Get, uri.clone()); let request = Request::get(uri.clone()).body(Body::empty()).unwrap();
Box::new(self.0.call(request).from_err().and_then(move |response| { Box::new(self.0.call(request).from_err().and_then(move |response| {
let status = response.status(); let status = response.status();
@ -103,7 +105,7 @@ where
try_future!(Err(anyhow!("Status code {} for URI {}", status, uri))); try_future!(Err(anyhow!("Status code {} for URI {}", status, uri)));
} }
let body_future = response.body().concat2().from_err(); let body_future = response.into_body().concat2().from_err();
let decode_future = body_future.and_then(move |body| { let decode_future = body_future.and_then(move |body| {
let string_body = str::from_utf8(body.as_ref())?; let string_body = str::from_utf8(body.as_ref())?;
let packages = string_body let packages = string_body
@ -152,42 +154,40 @@ pub struct GetPopularCrates<S>(pub S);
impl<S> Service for GetPopularCrates<S> impl<S> Service for GetPopularCrates<S>
where where
S: Service<Request = Request, Response = Response, Error = HyperError> + Clone + 'static, S: Service<Request = Request<Body>, Response = Response<Body>, Error = HyperError>
S::Future: 'static, + Clone
+ 'static,
S::Future: Send + 'static,
{ {
type Request = (); type Request = ();
type Response = Vec<CratePath>; type Response = Vec<CratePath>;
type Error = Error; type Error = Error;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>; type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error> + Send>;
fn call(&self, _req: ()) -> Self::Future { fn call(&self, _req: ()) -> Self::Future {
let service = self.0.clone(); let service = self.0.clone();
let uri_future = format!("{}/summary", CRATES_API_BASE_URI) let uri = format!("{}/summary", CRATES_API_BASE_URI)
.parse::<Uri>() .parse::<Uri>()
.into_future() .unwrap();
.from_err(); let request = Request::get(uri.clone()).body(Body::empty()).unwrap();
Box::new(uri_future.and_then(move |uri| { Box::new(service.call(request).from_err().and_then(move |response| {
let request = Request::new(Method::Get, uri.clone()); let status = response.status();
if !status.is_success() {
service.call(request).from_err().and_then(move |response| { future::Either::A(future::err(anyhow!(
let status = response.status(); "Status code {} for URI {}",
if !status.is_success() { status,
future::Either::A(future::err(anyhow!( uri
"Status code {} for URI {}", )))
status, } else {
uri let body_future = response.into_body().concat2().from_err();
))) let decode_future = body_future.and_then(|body| {
} else { let summary = serde_json::from_slice::<SummaryResponse>(&body)?;
let body_future = response.body().concat2().from_err(); convert_summary(summary)
let decode_future = body_future.and_then(|body| { });
let summary = serde_json::from_slice::<SummaryResponse>(&body)?; future::Either::B(decode_future)
convert_summary(summary) }
});
future::Either::B(decode_future)
}
})
})) }))
} }
} }

View file

@ -1,7 +1,7 @@
use anyhow::{anyhow, ensure, Error}; use anyhow::{anyhow, ensure, Error};
use futures::{Future, Stream}; use futures::{Future, Stream};
use hyper::header::UserAgent; use hyper::header::USER_AGENT;
use hyper::{Error as HyperError, Method, Request, Response, Uri}; use hyper::{Body, Error as HyperError, Method, Request, Response, Uri};
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use serde::Deserialize; use serde::Deserialize;
use tokio_service::Service; use tokio_service::Service;
@ -45,13 +45,15 @@ pub struct GetPopularRepos<S>(pub S);
impl<S> Service for GetPopularRepos<S> impl<S> Service for GetPopularRepos<S>
where where
S: Service<Request = Request, Response = Response, Error = HyperError> + Clone + 'static, S: Service<Request = Request<Body>, Response = Response<Body>, Error = HyperError>
S::Future: 'static, + Clone
+ 'static,
S::Future: Send + 'static,
{ {
type Request = (); type Request = ();
type Response = Vec<Repository>; type Response = Vec<Repository>;
type Error = Error; type Error = Error;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>; type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error> + Send>;
fn call(&self, _req: ()) -> Self::Future { fn call(&self, _req: ()) -> Self::Future {
let uri = try_future_box!(format!( let uri = try_future_box!(format!(
@ -60,8 +62,9 @@ where
) )
.parse::<Uri>()); .parse::<Uri>());
let mut request = Request::new(Method::Get, uri); let mut request = Request::get(uri);
request.headers_mut().set(UserAgent::new("deps.rs")); request.header(USER_AGENT, "deps.rs");
let request = request.body(Body::empty()).unwrap();
Box::new(self.0.call(request).from_err().and_then(|response| { Box::new(self.0.call(request).from_err().and_then(|response| {
let status = response.status(); let status = response.status();
@ -72,7 +75,7 @@ where
))); )));
} }
let body_future = response.body().concat2().from_err(); let body_future = response.into_body().concat2().from_err();
let decode_future = body_future let decode_future = body_future
.and_then(|body| serde_json::from_slice(body.as_ref()).map_err(|err| err.into())); .and_then(|body| serde_json::from_slice(body.as_ref()).map_err(|err| err.into()));
decode_future decode_future

View file

@ -1,6 +1,6 @@
use anyhow::{anyhow, ensure, Error}; use anyhow::{anyhow, ensure, Error};
use futures::{Future, Stream}; use futures::{Future, Stream};
use hyper::{Error as HyperError, Method, Request, Response}; use hyper::{Body, Error as HyperError, Method, Request, Response};
use relative_path::RelativePathBuf; use relative_path::RelativePathBuf;
use tokio_service::Service; use tokio_service::Service;
@ -17,13 +17,15 @@ pub struct RetrieveFileAtPath<S>(pub S);
impl<S> Service for RetrieveFileAtPath<S> impl<S> Service for RetrieveFileAtPath<S>
where where
S: Service<Request = Request, Response = Response, Error = HyperError> + Clone + 'static, S: Service<Request = Request<Body>, Response = Response<Body>, Error = HyperError>
S::Future: 'static, + Clone
+ 'static,
S::Future: Send + 'static,
{ {
type Request = (RepoPath, RelativePathBuf); type Request = (RepoPath, RelativePathBuf);
type Response = String; type Response = String;
type Error = Error; type Error = Error;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>; type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error> + Send>;
fn call(&self, req: Self::Request) -> Self::Future { fn call(&self, req: Self::Request) -> Self::Future {
let (repo_path, path) = req; let (repo_path, path) = req;
@ -33,7 +35,7 @@ where
&RepoSite::Bitbucket => try_future_box!(bitbucket::get_manifest_uri(&repo_path, &path)), &RepoSite::Bitbucket => try_future_box!(bitbucket::get_manifest_uri(&repo_path, &path)),
}; };
let request = Request::new(Method::Get, uri.clone()); let request = Request::get(uri.clone()).body(Body::empty()).unwrap();
Box::new(self.0.call(request).from_err().and_then(move |response| { Box::new(self.0.call(request).from_err().and_then(move |response| {
let status = response.status(); let status = response.status();
@ -41,7 +43,7 @@ where
try_future!(Err(anyhow!("Status code {} for URI {}", status, uri))); try_future!(Err(anyhow!("Status code {} for URI {}", status, uri)));
} }
let body_future = response.body().concat2().from_err(); let body_future = response.into_body().concat2().from_err();
body_future body_future
.and_then(|body| String::from_utf8(body.to_vec()).map_err(|err| err.into())) .and_then(|body| String::from_utf8(body.to_vec()).map_err(|err| err.into()))

View file

@ -3,7 +3,7 @@ use std::sync::Arc;
use anyhow::{anyhow, ensure, Error}; use anyhow::{anyhow, ensure, Error};
use futures::{future, future::done, Future, IntoFuture, Stream}; use futures::{future, future::done, Future, IntoFuture, Stream};
use hyper::{Error as HyperError, Method, Request, Response}; use hyper::{Body, Error as HyperError, Method, Request, Response};
use rustsec::database::Database; use rustsec::database::Database;
use rustsec::repository::DEFAULT_URL; use rustsec::repository::DEFAULT_URL;
use tokio_service::Service; use tokio_service::Service;
@ -13,13 +13,15 @@ pub struct FetchAdvisoryDatabase<S>(pub S);
impl<S> Service for FetchAdvisoryDatabase<S> impl<S> Service for FetchAdvisoryDatabase<S>
where where
S: Service<Request = Request, Response = Response, Error = HyperError> + Clone + 'static, S: Service<Request = Request<Body>, Response = Response<Body>, Error = HyperError>
+ Clone
+ 'static,
S::Future: 'static, S::Future: 'static,
{ {
type Request = (); type Request = ();
type Response = Arc<Database>; type Response = Arc<Database>;
type Error = Error; type Error = Error;
type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error>>; type Future = Box<dyn Future<Item = Self::Response, Error = Self::Error> + Send>;
fn call(&self, _req: ()) -> Self::Future { fn call(&self, _req: ()) -> Self::Future {
let service = self.0.clone(); let service = self.0.clone();

View file

@ -1,7 +1,6 @@
#![deny(rust_2018_idioms)] #![deny(rust_2018_idioms)]
#![allow(unused)] #![allow(unused)]
#[macro_use] #[macro_use]
extern crate try_future; extern crate try_future;
@ -11,7 +10,8 @@ use std::sync::Mutex;
use cadence::{QueuingMetricSink, UdpMetricSink}; use cadence::{QueuingMetricSink, UdpMetricSink};
use futures::{Future, Stream}; use futures::{Future, Stream};
use hyper::server::Http; use hyper::server::conn::AddrStream;
use hyper::service::{make_service_fn, service_fn_ok};
use hyper::Client; use hyper::Client;
use hyper_tls::HttpsConnector; use hyper_tls::HttpsConnector;
use slog::Drain; use slog::Drain;
@ -48,11 +48,9 @@ fn main() {
let handle = core.handle(); let handle = core.handle();
let connector = HttpsConnector::new(4, &handle).expect("failed to create https connector"); let connector = HttpsConnector::new(4).expect("failed to create https connector");
let client = Client::configure() let client = Client::builder().build(connector);
.connector(connector)
.build(&core.handle());
let port = env::var("PORT") let port = env::var("PORT")
.unwrap_or_else(|_| "8080".to_string()) .unwrap_or_else(|_| "8080".to_string())
@ -61,29 +59,18 @@ fn main() {
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), port); let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), port);
let http = Http::new();
let mut engine = Engine::new(client.clone(), logger.clone()); let mut engine = Engine::new(client.clone(), logger.clone());
engine.set_metrics(metrics); engine.set_metrics(metrics);
let server = Server::new(logger.clone(), engine); let server = Server::new(logger.clone(), engine);
let make_svc = make_service_fn(move |socket: &AddrStream| {
let serve = http let server = server.clone();
.serve_addr_handle(&addr, &handle, move || Ok(server.clone())) futures::future::ok::<_, hyper::Error>(server)
.expect("failed to bind server");
let serving = serve.for_each(move |conn| {
let conn_logger = logger.clone();
handle.spawn(conn.then(move |res| {
if let Err(err) = res {
info!(conn_logger, "server connection error: {}", err)
}
Ok(())
}));
Ok(())
}); });
let server = hyper::Server::bind(&addr).serve(make_svc);
println!("Server running on port {}", port); println!("Server running on port {}", port);
hyper::rt::run(server.map_err(|e| {
core.run(serving).expect("server failed"); eprintln!("server error: {}", e);
}));
} }

View file

@ -1,2 +1,2 @@
pub static STATIC_STYLE_CSS: &'static str = include_str!(concat!(env!("OUT_DIR"), "/style.css")); pub static STATIC_STYLE_CSS: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/style.css"));
pub static STATIC_FAVICON_PNG: &'static [u8; 1338] = include_bytes!("../../assets/favicon.png"); pub static STATIC_FAVICON_PNG: &[u8] = include_bytes!("../../assets/favicon.png");

View file

@ -2,14 +2,14 @@ use std::env;
use std::sync::Arc; use std::sync::Arc;
use futures::{future, Future, IntoFuture}; use futures::{future, Future, IntoFuture};
use hyper::header::{ContentType, Location}; use hyper::header::{CONTENT_TYPE, LOCATION};
use hyper::{Error as HyperError, Method, Request, Response, StatusCode}; use hyper::service::Service;
use hyper::{Body, Error as HyperError, Method, Request, Response, StatusCode};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use route_recognizer::{Params, Router}; use route_recognizer::{Params, Router};
use semver::VersionReq; use semver::VersionReq;
use slog::Logger; use slog::Logger;
use slog::{error, o}; use slog::{error, o};
use tokio_service::Service;
mod assets; mod assets;
mod views; mod views;
@ -83,12 +83,12 @@ impl Server {
} }
impl Service for Server { impl Service for Server {
type Request = Request; type ReqBody = Body;
type Response = Response; type ResBody = Body;
type Error = HyperError; type Error = hyper::Error;
type Future = Box<dyn Future<Item = Response, Error = HyperError>>; type Future = Box<dyn Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send>;
fn call(&self, req: Request) -> Self::Future { fn call(&mut self, req: Request<Self::ReqBody>) -> Self::Future {
let logger = self let logger = self
.logger .logger
.new(o!("http_path" => req.uri().path().to_owned())); .new(o!("http_path" => req.uri().path().to_owned()));
@ -96,17 +96,17 @@ impl Service for Server {
if let Ok(route_match) = self.router.recognize(req.uri().path()) { if let Ok(route_match) = self.router.recognize(req.uri().path()) {
match route_match.handler { match route_match.handler {
&Route::Index => { &Route::Index => {
if *req.method() == Method::Get { if *req.method() == Method::GET {
return Box::new(self.index(req, route_match.params, logger)); return Box::new(self.index(req, route_match.params, logger));
} }
} }
&Route::RepoStatus(format) => { &Route::RepoStatus(format) => {
if *req.method() == Method::Get { if *req.method() == Method::GET {
return Box::new(self.repo_status(req, route_match.params, logger, format)); return Box::new(self.repo_status(req, route_match.params, logger, format));
} }
} }
&Route::CrateStatus(format) => { &Route::CrateStatus(format) => {
if *req.method() == Method::Get { if *req.method() == Method::GET {
return Box::new(self.crate_status( return Box::new(self.crate_status(
req, req,
route_match.params, route_match.params,
@ -116,31 +116,31 @@ impl Service for Server {
} }
} }
&Route::CrateRedirect => { &Route::CrateRedirect => {
if *req.method() == Method::Get { if *req.method() == Method::GET {
return Box::new(self.crate_redirect(req, route_match.params, logger)); return Box::new(self.crate_redirect(req, route_match.params, logger));
} }
} }
&Route::Static(file) => { &Route::Static(file) => {
if *req.method() == Method::Get { if *req.method() == Method::GET {
return Box::new(future::ok(Server::static_file(file))); return Box::new(future::ok(Server::static_file(file)));
} }
} }
} }
} }
let mut response = Response::new(); let mut response = Response::builder();
response.set_status(StatusCode::NotFound); response.status(StatusCode::NOT_FOUND);
Box::new(future::ok(response)) Box::new(future::ok(response.body(Body::empty()).unwrap()))
} }
} }
impl Server { impl Server {
fn index( fn index(
&self, &self,
_req: Request, _req: Request<Body>,
_params: Params, _params: Params,
logger: Logger, logger: Logger,
) -> impl Future<Item = Response, Error = HyperError> { ) -> impl Future<Item = Response<Body>, Error = HyperError> + Send {
self.engine self.engine
.get_popular_repos() .get_popular_repos()
.join(self.engine.get_popular_crates()) .join(self.engine.get_popular_crates())
@ -149,7 +149,7 @@ impl Server {
error!(logger, "error: {}", err); error!(logger, "error: {}", err);
let mut response = let mut response =
views::html::error::render("Could not retrieve popular items", ""); views::html::error::render("Could not retrieve popular items", "");
response.set_status(StatusCode::InternalServerError); *response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
future::ok(response) future::ok(response)
} }
Ok((popular_repos, popular_crates)) => { Ok((popular_repos, popular_crates)) => {
@ -160,11 +160,11 @@ impl Server {
fn repo_status( fn repo_status(
&self, &self,
_req: Request, _req: Request<Body>,
params: Params, params: Params,
logger: Logger, logger: Logger,
format: StatusFormat, format: StatusFormat,
) -> impl Future<Item = Response, Error = HyperError> { ) -> impl Future<Item = Response<Body>, Error = HyperError> + Send {
let server = self.clone(); let server = self.clone();
let site = params.find("site").expect("route param 'site' not found"); let site = params.find("site").expect("route param 'site' not found");
@ -180,7 +180,7 @@ impl Server {
"Could not parse repository path", "Could not parse repository path",
"Please make sure to provide a valid repository path.", "Please make sure to provide a valid repository path.",
); );
response.set_status(StatusCode::BadRequest); *response.status_mut() = StatusCode::BAD_REQUEST;
future::Either::A(future::ok(response)) future::Either::A(future::ok(response))
} }
Ok(repo_path) => future::Either::B( Ok(repo_path) => future::Either::B(
@ -212,10 +212,10 @@ impl Server {
fn crate_redirect( fn crate_redirect(
&self, &self,
_req: Request, _req: Request<Body>,
params: Params, params: Params,
logger: Logger, logger: Logger,
) -> impl Future<Item = Response, Error = HyperError> { ) -> impl Future<Item = Response<Body>, Error = HyperError> + Send {
let engine = self.engine.clone(); let engine = self.engine.clone();
let name = params.find("name").expect("route param 'name' not found"); let name = params.find("name").expect("route param 'name' not found");
@ -229,7 +229,7 @@ impl Server {
"Could not parse crate name", "Could not parse crate name",
"Please make sure to provide a valid crate name.", "Please make sure to provide a valid crate name.",
); );
response.set_status(StatusCode::BadRequest); *response.status_mut() = StatusCode::BAD_REQUEST;
future::Either::A(future::ok(response)) future::Either::A(future::ok(response))
} }
Ok(crate_name) => future::Either::B( Ok(crate_name) => future::Either::B(
@ -242,7 +242,7 @@ impl Server {
"Could not fetch crate information", "Could not fetch crate information",
"Please make sure to provide a valid crate name.", "Please make sure to provide a valid crate name.",
); );
response.set_status(StatusCode::NotFound); *response.status_mut() = StatusCode::NOT_FOUND;
future::ok(response) future::ok(response)
} }
Ok(None) => { Ok(None) => {
@ -250,19 +250,21 @@ impl Server {
"Could not fetch crate information", "Could not fetch crate information",
"Please make sure to provide a valid crate name.", "Please make sure to provide a valid crate name.",
); );
response.set_status(StatusCode::NotFound); *response.status_mut() = StatusCode::NOT_FOUND;
future::ok(response) future::ok(response)
} }
Ok(Some(release)) => { Ok(Some(release)) => {
let mut response = Response::new(); let mut response = Response::builder();
response.set_status(StatusCode::TemporaryRedirect); response.status(StatusCode::TEMPORARY_REDIRECT);
let url = format!( let url = format!(
"{}/crate/{}/{}", "{}/crate/{}/{}",
&SELF_BASE_URL as &str, &SELF_BASE_URL as &str,
release.name.as_ref(), release.name.as_ref(),
release.version release.version
); );
response.headers_mut().set(Location::new(url)); response.header(LOCATION, url);
let response = response.body(Body::empty()).unwrap();
future::ok(response) future::ok(response)
} }
}), }),
@ -272,11 +274,11 @@ impl Server {
fn crate_status( fn crate_status(
&self, &self,
_req: Request, _req: Request<Body>,
params: Params, params: Params,
logger: Logger, logger: Logger,
format: StatusFormat, format: StatusFormat,
) -> impl Future<Item = Response, Error = HyperError> { ) -> impl Future<Item = Response<Body>, Error = HyperError> + Send {
let server = self.clone(); let server = self.clone();
let name = params.find("name").expect("route param 'name' not found"); let name = params.find("name").expect("route param 'name' not found");
@ -293,7 +295,7 @@ impl Server {
"Could not parse crate path", "Could not parse crate path",
"Please make sure to provide a valid crate name and version.", "Please make sure to provide a valid crate name and version.",
); );
response.set_status(StatusCode::BadRequest); *response.status_mut() = StatusCode::BAD_REQUEST;
future::Either::A(future::ok(response)) future::Either::A(future::ok(response))
} }
Ok(crate_path) => future::Either::B( Ok(crate_path) => future::Either::B(
@ -327,21 +329,23 @@ impl Server {
analysis_outcome: Option<AnalyzeDependenciesOutcome>, analysis_outcome: Option<AnalyzeDependenciesOutcome>,
format: StatusFormat, format: StatusFormat,
subject_path: SubjectPath, subject_path: SubjectPath,
) -> Response { ) -> Response<Body> {
match format { match format {
StatusFormat::Svg => views::badge::response(analysis_outcome.as_ref()), StatusFormat::Svg => views::badge::response(analysis_outcome.as_ref()),
StatusFormat::Html => views::html::status::render(analysis_outcome, subject_path), StatusFormat::Html => views::html::status::render(analysis_outcome, subject_path),
} }
} }
fn static_file(file: StaticFile) -> Response { fn static_file(file: StaticFile) -> Response<Body> {
match file { match file {
StaticFile::StyleCss => Response::new() StaticFile::StyleCss => Response::builder()
.with_header(ContentType("text/css".parse().unwrap())) .header(CONTENT_TYPE, "text/css")
.with_body(assets::STATIC_STYLE_CSS), .body(Body::from(assets::STATIC_STYLE_CSS))
StaticFile::FaviconPng => Response::new() .unwrap(),
.with_header(ContentType("image/png".parse().unwrap())) StaticFile::FaviconPng => Response::builder()
.with_body(assets::STATIC_FAVICON_PNG.to_vec()), .header(CONTENT_TYPE, "image/png")
.body(Body::from(assets::STATIC_FAVICON_PNG))
.unwrap(),
} }
} }
} }

View file

@ -1,6 +1,6 @@
use badge::{Badge, BadgeOptions}; use badge::{Badge, BadgeOptions};
use hyper::header::ContentType; use hyper::header::CONTENT_TYPE;
use hyper::Response; use hyper::{Body, Response};
use crate::engine::AnalyzeDependenciesOutcome; use crate::engine::AnalyzeDependenciesOutcome;
@ -47,8 +47,11 @@ pub fn badge(analysis_outcome: Option<&AnalyzeDependenciesOutcome>) -> Badge {
Badge::new(opts) Badge::new(opts)
} }
pub fn response(analysis_outcome: Option<&AnalyzeDependenciesOutcome>) -> Response { pub fn response(analysis_outcome: Option<&AnalyzeDependenciesOutcome>) -> Response<Body> {
Response::new() let badge = badge(analysis_outcome).to_svg();
.with_header(ContentType("image/svg+xml;charset=utf-8".parse().unwrap()))
.with_body(badge(analysis_outcome).to_svg().into_bytes()) Response::builder()
.header(CONTENT_TYPE, "image/svg+xml; charset=utf-8")
.body(Body::from(badge))
.unwrap()
} }

View file

@ -1,7 +1,7 @@
use hyper::Response; use hyper::{Body, Response};
use maud::html; use maud::html;
pub fn render(title: &str, descr: &str) -> Response { pub fn render(title: &str, descr: &str) -> Response<Body> {
super::render_html( super::render_html(
title, title,
html! { html! {

View file

@ -1,4 +1,4 @@
use hyper::Response; use hyper::{Body, Response};
use maud::{html, Markup}; use maud::{html, Markup};
use crate::models::crates::CratePath; use crate::models::crates::CratePath;
@ -63,7 +63,7 @@ fn popular_table(popular_repos: Vec<Repository>, popular_crates: Vec<CratePath>)
} }
} }
pub fn render(popular_repos: Vec<Repository>, popular_crates: Vec<CratePath>) -> Response { pub fn render(popular_repos: Vec<Repository>, popular_crates: Vec<CratePath>) -> Response<Body> {
super::render_html( super::render_html(
"Keep your dependencies up-to-date", "Keep your dependencies up-to-date",
html! { html! {

View file

@ -1,7 +1,7 @@
use std::time::Duration; use std::time::Duration;
use hyper::header::ContentType; use hyper::header::CONTENT_TYPE;
use hyper::Response; use hyper::{Body, Response};
use maud::{html, Markup, Render}; use maud::{html, Markup, Render};
pub mod error; pub mod error;
@ -10,7 +10,7 @@ pub mod status;
use super::super::SELF_BASE_URL; use super::super::SELF_BASE_URL;
fn render_html<B: Render>(title: &str, body: B) -> Response { fn render_html<B: Render>(title: &str, body: B) -> Response<Body> {
let rendered = html! { let rendered = html! {
html { html {
head { head {
@ -27,9 +27,10 @@ fn render_html<B: Render>(title: &str, body: B) -> Response {
} }
}; };
Response::new() Response::builder()
.with_header(ContentType::html()) .header(CONTENT_TYPE, "text/html; charset=utf-8")
.with_body(rendered.0) .body(Body::from(rendered.0))
.unwrap()
} }
fn render_navbar() -> Markup { fn render_navbar() -> Markup {

View file

@ -1,4 +1,4 @@
use hyper::Response; use hyper::{Body, Response};
use indexmap::IndexMap; use indexmap::IndexMap;
use maud::{html, Markup}; use maud::{html, Markup};
@ -205,7 +205,7 @@ fn render_success(
pub fn render( pub fn render(
analysis_outcome: Option<AnalyzeDependenciesOutcome>, analysis_outcome: Option<AnalyzeDependenciesOutcome>,
subject_path: SubjectPath, subject_path: SubjectPath,
) -> Response { ) -> Response<Body> {
let title = match subject_path { let title = match subject_path {
SubjectPath::Repo(ref repo_path) => { SubjectPath::Repo(ref repo_path) => {
format!("{} / {}", repo_path.qual.as_ref(), repo_path.name.as_ref()) format!("{} / {}", repo_path.qual.as_ref(), repo_path.name.as_ref())