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
use HashMap;
use Bytes;
/// A chunk in a streaming response from a PHP worker.
///
/// The worker emits a sequence ending with [`End`]. Consumers read until `End`
/// (or the channel closes) to obtain the complete response.
///
/// A worker finalises a request in one of three shapes:
///
/// * **streaming** — one [`Headers`] chunk followed by zero or more [`Body`]
/// chunks (the PHP `folk_write_head` / `folk_write` API);
/// * **return** — a single [`Return`] chunk carrying the handler's return value
/// verbatim (non-streaming handlers: gRPC, jobs, and HTTP that `return`s an
/// array);
/// * **error** — a single [`Error`] chunk carrying a fatal [`WorkerError`]
/// (uncaught exception, dispatch failure, malformed response).
///
/// Each shape is terminated by [`End`]. Consumers interpret `Return` themselves:
/// the HTTP plugin decodes the `{status, headers, body}` convention, while
/// gRPC/jobs use the value as-is.
///
/// [`Headers`]: ResponseChunk::Headers
/// [`Body`]: ResponseChunk::Body
/// [`Return`]: ResponseChunk::Return
/// [`Error`]: ResponseChunk::Error
/// [`End`]: ResponseChunk::End
/// A fatal error raised while a PHP worker handled a request.
///
/// Carries the human-readable message and, **in dev mode only**, the exception
/// class and stack trace. In production `exception_class` / `stacktrace` are
/// `None` to avoid leaking internals to clients; the full detail is still
/// logged server-side.