Revert "update to tokio 1.0 (#1246)"

This reverts commit 741b6bf830.
This commit is contained in:
Vincent Prouillet 2021-01-05 21:51:44 +01:00
parent 741b6bf830
commit fc79225267
3 changed files with 92 additions and 277 deletions

309
Cargo.lock generated
View file

@ -62,27 +62,6 @@ dependencies = [
"serde_json", "serde_json",
] ]
[[package]]
name = "async-stream"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c"
dependencies = [
"async-stream-impl",
"futures-core",
]
[[package]]
name = "async-stream-impl"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "atty" name = "atty"
version = "0.2.14" version = "0.2.14"
@ -204,12 +183,6 @@ version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
[[package]]
name = "bytes"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad1f8e949d755f9d79112b5bb46938e0ef9d3804a0b16dfab13aafcaa5f0fa72"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.60" version = "1.0.60"
@ -231,12 +204,6 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.18" version = "0.4.18"
@ -320,7 +287,7 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
] ]
[[package]] [[package]]
@ -351,7 +318,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if 0.1.10", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
"lazy_static", "lazy_static",
"maybe-uninit", "maybe-uninit",
@ -366,7 +333,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if 0.1.10", "cfg-if",
"lazy_static", "lazy_static",
] ]
@ -548,7 +515,7 @@ version = "0.8.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2" checksum = "a51b8cf747471cb9499b6d59e59b0444f4c90eba8968c4e44874e92b5b64ace2"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
] ]
[[package]] [[package]]
@ -585,7 +552,7 @@ version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e" checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"libc", "libc",
"redox_syscall", "redox_syscall",
"winapi 0.3.9", "winapi 0.3.9",
@ -597,7 +564,7 @@ version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94" checksum = "766d0e77a2c1502169d4a93ff3b8c15a71fd946cd0126309752104e5f3c46d94"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"crc32fast", "crc32fast",
"libc", "libc",
"miniz_oxide 0.4.2", "miniz_oxide 0.4.2",
@ -728,7 +695,7 @@ dependencies = [
"futures-macro", "futures-macro",
"futures-task", "futures-task",
"memchr", "memchr",
"pin-project 0.4.24", "pin-project",
"pin-utils", "pin-utils",
"proc-macro-hack", "proc-macro-hack",
"proc-macro-nested", "proc-macro-nested",
@ -760,7 +727,7 @@ version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"libc", "libc",
"wasi 0.9.0+wasi-snapshot-preview1", "wasi 0.9.0+wasi-snapshot-preview1",
] ]
@ -819,31 +786,11 @@ dependencies = [
"http", "http",
"indexmap", "indexmap",
"slab", "slab",
"tokio 0.2.22", "tokio",
"tokio-util 0.3.1", "tokio-util",
"tracing", "tracing",
] ]
[[package]]
name = "h2"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5"
dependencies = [
"bytes 1.0.0",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http",
"indexmap",
"slab",
"tokio 1.0.1",
"tokio-util 0.6.0",
"tracing",
"tracing-futures",
]
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.8.2" version = "0.8.2"
@ -913,16 +860,6 @@ dependencies = [
"http", "http",
] ]
[[package]]
name = "http-body"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994"
dependencies = [
"bytes 1.0.0",
"http",
]
[[package]] [[package]]
name = "httparse" name = "httparse"
version = "1.3.4" version = "1.3.4"
@ -951,39 +888,15 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2 0.2.6", "h2",
"http", "http",
"http-body 0.3.1", "http-body",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
"pin-project 0.4.24", "pin-project",
"socket2", "socket2",
"tokio 0.2.22", "tokio",
"tower-service",
"tracing",
"want",
]
[[package]]
name = "hyper"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7b980c7bc75203b968f06374cbde00bf1818e02e156b8e5b6ccf440fb53b6d0"
dependencies = [
"bytes 1.0.0",
"futures-channel",
"futures-core",
"futures-util",
"h2 0.3.0",
"http",
"http-body 0.4.0",
"httparse",
"httpdate",
"itoa",
"pin-project 1.0.2",
"socket2",
"tokio 1.0.1",
"tower-service", "tower-service",
"tracing", "tracing",
"want", "want",
@ -997,14 +910,31 @@ checksum = "37743cc83e8ee85eacfce90f2f4102030d9ff0a95244098d781e9bee4a90abb6"
dependencies = [ dependencies = [
"bytes 0.5.6", "bytes 0.5.6",
"futures-util", "futures-util",
"hyper 0.13.8", "hyper",
"log", "log",
"rustls", "rustls",
"tokio 0.2.22", "tokio",
"tokio-rustls", "tokio-rustls",
"webpki", "webpki",
] ]
[[package]]
name = "hyper-staticfile"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f059991575d4be26e3946276a4f3ee24bcf17a232449407354045eaf064d3475"
dependencies = [
"chrono",
"futures-util",
"http",
"hyper",
"mime_guess",
"percent-encoding",
"tokio",
"url",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.2.0" version = "0.2.0"
@ -1301,7 +1231,7 @@ version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
] ]
[[package]] [[package]]
@ -1430,32 +1360,19 @@ version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"fuchsia-zircon", "fuchsia-zircon",
"fuchsia-zircon-sys", "fuchsia-zircon-sys",
"iovec", "iovec",
"kernel32-sys", "kernel32-sys",
"libc", "libc",
"log", "log",
"miow 0.2.1", "miow",
"net2", "net2",
"slab", "slab",
"winapi 0.2.8", "winapi 0.2.8",
] ]
[[package]]
name = "mio"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f33bc887064ef1fd66020c9adfc45bb9f33d75a42096c81e7c56c65b75dd1a8b"
dependencies = [
"libc",
"log",
"miow 0.3.6",
"ntapi",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "mio-extras" name = "mio-extras"
version = "2.0.6" version = "2.0.6"
@ -1464,7 +1381,7 @@ checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
dependencies = [ dependencies = [
"lazycell", "lazycell",
"log", "log",
"mio 0.6.22", "mio",
"slab", "slab",
] ]
@ -1480,16 +1397,6 @@ dependencies = [
"ws2_32-sys", "ws2_32-sys",
] ]
[[package]]
name = "miow"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
dependencies = [
"socket2",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "mockito" name = "mockito"
version = "0.27.0" version = "0.27.0"
@ -1514,7 +1421,7 @@ version = "0.2.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"libc", "libc",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -1533,7 +1440,7 @@ checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cc", "cc",
"cfg-if 0.1.10", "cfg-if",
"libc", "libc",
"void", "void",
] ]
@ -1550,21 +1457,12 @@ dependencies = [
"fsevent-sys", "fsevent-sys",
"inotify", "inotify",
"libc", "libc",
"mio 0.6.22", "mio",
"mio-extras", "mio-extras",
"walkdir", "walkdir",
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi 0.3.9",
]
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.43" version = "0.1.43"
@ -1767,16 +1665,7 @@ version = "0.4.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f48fad7cfbff853437be7cf54d7b993af21f53be7f0988cbfe4a51535aa77205" checksum = "f48fad7cfbff853437be7cf54d7b993af21f53be7f0988cbfe4a51535aa77205"
dependencies = [ dependencies = [
"pin-project-internal 0.4.24", "pin-project-internal",
]
[[package]]
name = "pin-project"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7"
dependencies = [
"pin-project-internal 1.0.2",
] ]
[[package]] [[package]]
@ -1790,29 +1679,12 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "pin-project-internal"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.1.8" version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71f349a4f0e70676ffb2dbafe16d0c992382d02f0a952e3ddf584fc289dac6b3" checksum = "71f349a4f0e70676ffb2dbafe16d0c992382d02f0a952e3ddf584fc289dac6b3"
[[package]]
name = "pin-project-lite"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
version = "0.1.0" version = "0.1.0"
@ -2091,8 +1963,8 @@ dependencies = [
"futures-core", "futures-core",
"futures-util", "futures-util",
"http", "http",
"http-body 0.3.1", "http-body",
"hyper 0.13.8", "hyper",
"hyper-rustls", "hyper-rustls",
"ipnet", "ipnet",
"js-sys", "js-sys",
@ -2101,11 +1973,11 @@ dependencies = [
"mime", "mime",
"mime_guess", "mime_guess",
"percent-encoding", "percent-encoding",
"pin-project-lite 0.1.8", "pin-project-lite",
"rustls", "rustls",
"serde", "serde",
"serde_urlencoded", "serde_urlencoded",
"tokio 0.2.22", "tokio",
"tokio-rustls", "tokio-rustls",
"url", "url",
"wasm-bindgen", "wasm-bindgen",
@ -2302,7 +2174,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1" checksum = "2933378ddfeda7ea26f48c555bdad8bb446bf8a3d17832dc83e380d444cfb8c1"
dependencies = [ dependencies = [
"block-buffer 0.9.0", "block-buffer 0.9.0",
"cfg-if 0.1.10", "cfg-if",
"cpuid-bool", "cpuid-bool",
"digest 0.9.0", "digest 0.9.0",
"opaque-debug 0.3.0", "opaque-debug 0.3.0",
@ -2368,12 +2240,13 @@ checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.3.19" version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"redox_syscall",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -2446,9 +2319,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.55" version = "1.0.42"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a571a711dddd09019ccc628e1b17fe87c59b09d513c06c026877aa708334f37a" checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2483,7 +2356,7 @@ 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 = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"libc", "libc",
"rand", "rand",
"redox_syscall", "redox_syscall",
@ -2615,24 +2488,22 @@ dependencies = [
"iovec", "iovec",
"lazy_static", "lazy_static",
"memchr", "memchr",
"mio 0.6.22", "mio",
"num_cpus", "num_cpus",
"pin-project-lite 0.1.8", "pin-project-lite",
"slab", "slab",
"tokio-macros",
] ]
[[package]] [[package]]
name = "tokio" name = "tokio-macros"
version = "1.0.1" version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d258221f566b6c803c7b4714abadc080172b272090cdc5e244a6d4dd13c3a6bd" checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389"
dependencies = [ dependencies = [
"autocfg", "proc-macro2",
"bytes 1.0.0", "quote",
"libc", "syn",
"memchr",
"mio 0.7.6",
"pin-project-lite 0.2.0",
] ]
[[package]] [[package]]
@ -2643,22 +2514,10 @@ checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"rustls", "rustls",
"tokio 0.2.22", "tokio",
"webpki", "webpki",
] ]
[[package]]
name = "tokio-stream"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f3be913b74b13210c8fe04b17ab833f5a124f45b93d0f99f59fff621f64392a"
dependencies = [
"async-stream",
"futures-core",
"pin-project-lite 0.2.0",
"tokio 1.0.1",
]
[[package]] [[package]]
name = "tokio-util" name = "tokio-util"
version = "0.3.1" version = "0.3.1"
@ -2669,23 +2528,8 @@ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"log", "log",
"pin-project-lite 0.1.8", "pin-project-lite",
"tokio 0.2.22", "tokio",
]
[[package]]
name = "tokio-util"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36135b7e7da911f5f8b9331209f7fab4cc13498f3fff52f72a710c78187e3148"
dependencies = [
"bytes 1.0.0",
"futures-core",
"futures-sink",
"log",
"pin-project-lite 0.2.0",
"tokio 1.0.1",
"tokio-stream",
] ]
[[package]] [[package]]
@ -2709,7 +2553,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 = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c" checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"log", "log",
"tracing-core", "tracing-core",
] ]
@ -2723,16 +2567,6 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "tracing-futures"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c"
dependencies = [
"pin-project 0.4.24",
"tracing",
]
[[package]] [[package]]
name = "try-lock" name = "try-lock"
version = "0.2.3" version = "0.2.3"
@ -2949,7 +2783,7 @@ version = "0.2.68"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42" checksum = "1ac64ead5ea5f05873d7c12b545865ca2b8d28adfc50a49b84770a3a97265d42"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"serde", "serde",
"serde_json", "serde_json",
"wasm-bindgen-macro", "wasm-bindgen-macro",
@ -2976,7 +2810,7 @@ version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da" checksum = "b7866cab0aa01de1edf8b5d7936938a7e397ee50ce24119aef3e1eaa3b6171da"
dependencies = [ dependencies = [
"cfg-if 0.1.10", "cfg-if",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -3108,7 +2942,7 @@ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"httparse", "httparse",
"log", "log",
"mio 0.6.22", "mio",
"mio-extras", "mio-extras",
"rand", "rand",
"sha-1", "sha-1",
@ -3170,14 +3004,15 @@ dependencies = [
"errors", "errors",
"front_matter", "front_matter",
"globset", "globset",
"hyper 0.14.1", "hyper",
"hyper-staticfile",
"lazy_static", "lazy_static",
"notify", "notify",
"open", "open",
"relative-path", "relative-path",
"site", "site",
"termcolor", "termcolor",
"tokio 1.0.1", "tokio",
"url", "url",
"utils", "utils",
"ws", "ws",

View file

@ -27,8 +27,9 @@ termcolor = "1.0.4"
# Used in init to ensure the url given as base_url is a valid one # Used in init to ensure the url given as base_url is a valid one
url = "2" url = "2"
# Below is for the serve cmd # Below is for the serve cmd
hyper = { version = "0.14.1", default-features = false, features = ["runtime", "server", "http2", "http1"] } hyper = { version = "0.13", default-features = false, features = ["runtime"] }
tokio = { version = "1.0.1", default-features = false, features = ["rt", "fs"] } hyper-staticfile = "0.5"
tokio = { version = "0.2", default-features = false, features = [] }
notify = "4" notify = "4"
ws = "0.9" ws = "0.9"
ctrlc = "3" ctrlc = "3"

View file

@ -22,16 +22,16 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
use std::fs::{read_dir, remove_dir_all}; use std::fs::{read_dir, remove_dir_all};
use std::net::{SocketAddrV4, TcpListener};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::thread; use std::thread;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use std::net::{SocketAddrV4, TcpListener};
use hyper::header; use hyper::header;
use hyper::server::Server;
use hyper::service::{make_service_fn, service_fn}; use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Method, Request, Response, StatusCode}; use hyper::{Body, Method, Request, Response, Server, StatusCode};
use hyper_staticfile::ResolveResult;
use chrono::prelude::*; use chrono::prelude::*;
use notify::{watcher, RecursiveMode, Watcher}; use notify::{watcher, RecursiveMode, Watcher};
@ -70,7 +70,7 @@ static NOT_FOUND_TEXT: &[u8] = b"Not Found";
// This is dist/livereload.min.js from the LiveReload.js v3.2.4 release // This is dist/livereload.min.js from the LiveReload.js v3.2.4 release
const LIVE_RELOAD: &str = include_str!("livereload.js"); const LIVE_RELOAD: &str = include_str!("livereload.js");
async fn handle_request(req: Request<Body>, mut root: PathBuf) -> Result<Response<Body>> { async fn handle_request(req: Request<Body>, root: PathBuf) -> Result<Response<Body>> {
let mut path = RelativePathBuf::new(); let mut path = RelativePathBuf::new();
for c in req.uri().path().split('/') { for c in req.uri().path().split('/') {
@ -90,37 +90,18 @@ async fn handle_request(req: Request<Body>, mut root: PathBuf) -> Result<Respons
return Ok(in_memory_html(content)); return Ok(in_memory_html(content));
} }
// Handle only `GET`/`HEAD` requests let result = hyper_staticfile::resolve(&root, &req).await.unwrap();
match *req.method() { match result {
Method::HEAD | Method::GET => {} ResolveResult::MethodNotMatched => return Ok(method_not_allowed()),
_ => return Ok(method_not_allowed()), ResolveResult::NotFound | ResolveResult::UriNotMatched => {
} let not_found_path = RelativePath::new("404.html");
let content_404 = SITE_CONTENT.read().unwrap().get(not_found_path).cloned();
// Handle only simple path requests return Ok(not_found(content_404));
if req.uri().scheme_str().is_some() || req.uri().host().is_some() { }
return Ok(not_found()); _ => (),
}
// Remove the trailing slash from the request path
// otherwise `PathBuf` will interpret it as an absolute path
root.push(&req.uri().path()[1..]);
let result = tokio::fs::read(root).await;
let contents = match result {
Err(err) => match err.kind() {
std::io::ErrorKind::NotFound => return Ok(not_found()),
std::io::ErrorKind::PermissionDenied => {
return Ok(Response::builder()
.status(StatusCode::FORBIDDEN)
.body(Body::empty())
.unwrap())
}
_ => panic!("{}", err),
},
Ok(contents) => contents,
}; };
Ok(Response::builder().status(StatusCode::OK).body(Body::from(contents)).unwrap()) Ok(hyper_staticfile::ResponseBuilder::new().request(&req).build(result).unwrap())
} }
fn livereload_js() -> Response<Body> { fn livereload_js() -> Response<Body> {
@ -147,10 +128,7 @@ fn method_not_allowed() -> Response<Body> {
.expect("Could not build Method Not Allowed response") .expect("Could not build Method Not Allowed response")
} }
fn not_found() -> Response<Body> { fn not_found(content: Option<String>) -> Response<Body> {
let not_found_path = RelativePath::new("404.html");
let content = SITE_CONTENT.read().unwrap().get(not_found_path).cloned();
if let Some(body) = content { if let Some(body) = content {
return Response::builder() return Response::builder()
.header(header::CONTENT_TYPE, "text/html") .header(header::CONTENT_TYPE, "text/html")
@ -308,8 +286,9 @@ pub fn serve(
thread::spawn(move || { thread::spawn(move || {
let addr = address.parse().unwrap(); let addr = address.parse().unwrap();
let rt = tokio::runtime::Builder::new_current_thread() let mut rt = tokio::runtime::Builder::new()
.enable_all() .enable_all()
.basic_scheduler()
.build() .build()
.expect("Could not build tokio runtime"); .expect("Could not build tokio runtime");