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
//! Request-level `Accept` override.
//!
//! Generated [`MakeRequest`] impls auto-emit an `Accept` header that
//! enumerates every response media type declared in the spec, in
//! codec-priority order. That covers the common case but leaves no room
//! for callers who want to *steer* content negotiation toward one
//! specific branch — e.g. asking OpenAI's chat completion endpoint for
//! `text/event-stream` to land on the streaming response.
//!
//! [`WithAccept`] is the runtime adapter that drives this: wrap any
//! operation value, give it the [`http::HeaderValue`] you want on the
//! wire, and the wrapper rewrites the `Accept` header after the inner
//! op finishes its `MakeRequest::make_request` work. Because the
//! override happens after `make_request` returns, the inner op's other
//! header / body / extension wiring is preserved as-is.
//!
//! Usage from generated code:
//!
//! ```ignore
//! use ::http::HeaderValue;
//! use toac::WithAccept;
//!
//! let op = create_chat_completion::Request { body: ... };
//! let op = WithAccept::new(op, HeaderValue::from_static("text/event-stream"));
//! client.call(op).await?;
//! ```
use ;
use crate::;
/// Operation wrapper that overrides the `Accept` header the inner op
/// would emit.
///
/// The wrapper passes the operation through unchanged otherwise — same
/// method, URI, body, extensions, and other headers. Only `Accept` is
/// replaced (any pre-existing `Accept` header is removed first, so the
/// override is single-valued on the wire).