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
//! HTTP utilities used only by the server crate.
//!
//! `normalize_url_path` previously lived alongside these but moved to
//! `apimock-routing::util::http` in 5.0 — the matcher needs it; these
//! two helpers are HTTP-layer only.
use ;
use time;
use Duration;
/// Inspect `Content-Type` to decide whether a request body should be
/// parsed as JSON.
///
/// Returns:
/// - `Some(true)` — header is present and starts with `application/json`
/// (supports `application/json; charset=utf-8` and similar).
/// - `Some(false)` — header is present but is something else.
/// - `None` — header is absent, so we can't tell.
///
/// The three-valued return is deliberate: callers treat "absent" and
/// "present-but-wrong" differently (the first is a common shortcut, the
/// second is a likely client bug).
/// Sleep `milliseconds` ms on the async runtime.
///
/// Used by `respond.delay_response_milliseconds` to simulate slow
/// backends when a mock needs to exercise client timeout behaviour.
pub async