You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/utils/get_header.dart
+38
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,56 @@ import 'dart:io';
2
2
3
3
import'package:h4/src/event.dart';
4
4
5
+
/// ### Retrieves the value of a specific header from an event instance.
6
+
///
7
+
/// The `getHeader` function is used to extract the value of a specified header from an `H4Event` object. The `H4Event` object is expected to have a `node` property that contains an HTTP request, and the `node["value"]` property is assumed to represent the incoming HTTP request.
8
+
///
9
+
/// Parameters:
10
+
/// - `event`: An `H4Event` instance.
11
+
/// - `header`: The name of the header to retrieve.
12
+
///
13
+
/// Returns:
14
+
/// The value of the specified header, or `null` if the header is not found.
/// Retrieves the headers of the incoming HTTP request from an `H4Event` instance.
20
+
///
21
+
/// The `getRequestHeaders` function is used to extract the headers of the incoming HTTP request from an `H4Event` object. The `H4Event` object is expected to have a `node` property that contains the HTTP request, and the `node["value"]` property is assumed to represent the incoming HTTP request.
22
+
///
23
+
/// Parameters:
24
+
/// - `event`: An `H4Event` instance containing the HTTP request.
25
+
///
26
+
/// Returns:
27
+
/// The headers of the incoming HTTP request.
9
28
HttpHeaders?getRequestHeaders(H4Event event) {
10
29
return event.node["value"]?.headers;
11
30
}
12
31
32
+
/// Retrieves the headers of the HTTP response from an `H4Event` instance.
33
+
///
34
+
/// The `getResponseHeaders` function is used to extract the headers of the HTTP response from an `H4Event` object. The `H4Event` object is expected to have a `node` property that contains the HTTP request, and the `node["value"]` property is assumed to represent the incoming HTTP request.
35
+
///
36
+
/// Parameters:
37
+
/// - `event`: An `H4Event` instance containing the HTTP request.
38
+
///
39
+
/// Returns:
40
+
/// The headers of the HTTP response, or `null` if the response is `null`.
13
41
HttpHeaders?getResponseHeaders(H4Event event) {
14
42
return event.node["value"]?.response.headers;
15
43
}
16
44
45
+
/// Retrieves the value of a specific header in the HTTP response from an `H4Event` instance.
46
+
///
47
+
/// The `getResponseHeader` function is used to extract the value of a specified header from the HTTP response of an `H4Event` object. The `H4Event` object is expected to have a `node` property that contains the HTTP request, and the `node["value"]` property is assumed to represent the incoming HTTP request.
48
+
///
49
+
/// Parameters:
50
+
/// - `event`: An `H4Event` instance containing the HTTP request.
51
+
/// - `header`: The name of the header to retrieve.
52
+
///
53
+
/// Returns:
54
+
/// The value of the specified header, or `null` if the header is not found or the response is `null`.
0 commit comments