1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Shared HTTP client used by every fetch in the crate.
//!
//! Single lazy built client cloned per request. reqwest pools
//! connections and caches DNS internally so a long lived client
//! is the right shape but the same internal state can get stuck
//! in ways that look like network failure and won't recover on
//! their own. `reset_http_client` is the ejection seat.
use crate;
use RwLock;
use Duration;
const USER_AGENT: &str =
"(weathervane, https://gitlab.com/vintagetechie/weathervane)";
/// Per-request timeout applied to all outgoing HTTP calls.
const REQUEST_TIMEOUT: Duration = from_secs;
/// Kernel TCP keepalive interval. Probes detect dead peers without
/// waiting for the full request timeout.
const TCP_KEEPALIVE: Duration = from_secs;
/// How long an idle pooled connection can sit before being dropped.
const POOL_IDLE_TIMEOUT: Duration = from_secs;
static CLIENT: = new;
/// Returns a clone of the shared HTTP client, building it on first use.
pub
/// Throws away the shared HTTP client. Next request builds a new one.
///
/// For when something inside reqwest is stuck and you'd rather start
/// over than figure out what.