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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! HTTP fetch backend abstraction.
//!
//! [`HttpClient`] is the trait boundary between the `fetch` tool and the underlying HTTP
//! stack. The concrete implementation comes from [`defect-http`]; during session assembly
//! the CLI injects `Arc<dyn HttpClient>` into [`crate::session::AgentCore`], propagated
//! through [`crate::tool::ToolContext`] to tools.
//!
//! Unlike [`crate::fs::FsBackend`] / [`crate::shell::ShellBackend`], HTTP has no
//! per-client capability negotiation, so [`HttpClient`] is shared at the process level
//! rather than assembled per session; it simply reuses the same `Arc<dyn …>` injection
//! pattern to avoid introducing a new injection path.
//!
//! [`defect-http`]: ../../../crates/http
use Duration;
use BoxFuture;
use Error;
use crateBoxError;
/// An HTTP fetch request.
///
/// Currently `GET`-only — the `fetch` tool's schema also exposes only read semantics, not
/// method / header / body / auth.
/// A response that was fetched successfully.
///
/// `status` is the status code of the final response (after following redirects);
/// `final_url` is analogous.
/// HTTP fetch backend trait.
///
/// Implementors must satisfy the following contract:
/// - `fetch` must internally enforce the total timeout from `req.timeout` (including
/// connect and read body);
/// on timeout, return [`HttpClientError::Timeout`].
/// - When `req.follow_redirects = true`, follow 3xx responses per RFC 7231, up to
/// `req.max_redirects` hops; exceeding that returns
/// [`HttpClientError::TooManyRedirects`].
/// - When reading the body, stop after accumulating `req.max_response_bytes` and set
/// `truncated = true` on the response.
/// - Any HTTP status (including 4xx/5xx) is considered a success
/// ([`HttpResponse::status`]
/// is returned as-is); only transport or decode failures should return `Err`.
/// A placeholder implementation for testing or an `echo` provider. Every `fetch` call
/// returns
/// [`HttpClientError::Transport`], allowing assembly paths that require `Arc<dyn
/// HttpClient>`
/// to skip constructing a real HTTP stack.
;