crossbind 2.0.0-beta.63 → 2.0.0-beta.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -1
- package/package.json +2 -2
- package/src/actions/androidDevice.js +77 -0
- package/src/actions/androidGradle.js +121 -0
- package/src/actions/buildApp.js +434 -0
- package/src/actions/buildBinTools.js +0 -0
- package/src/actions/buildDependencies.js +4 -3
- package/src/actions/buildExternal.js +3 -3
- package/src/actions/buildJs.js +2 -9
- package/src/actions/buildLib.js +1 -1
- package/src/actions/buildNode.js +19 -16
- package/src/actions/buildWasiCommand.js +10 -5
- package/src/actions/buildWasm.js +24 -3
- package/src/actions/createImportedBridges.js +7 -0
- package/src/actions/createInterface.js +4 -5
- package/src/actions/createLib.js +17 -2
- package/src/actions/getCmakeParameters.js +2 -1
- package/src/actions/getData.js +2 -1
- package/src/actions/getDependLibs.js +8 -2
- package/src/actions/getEnv.js +7 -0
- package/src/actions/getLinkInputs.js +10 -7
- package/src/actions/gradleProject.js +110 -0
- package/src/actions/iosSimulator.js +63 -0
- package/src/actions/licenses.js +160 -14
- package/src/actions/nativeBridges.js +35 -0
- package/src/actions/run.js +3 -3
- package/src/actions/runnerCommands.js +16 -4
- package/src/actions/target.js +2 -1
- package/src/actions/writeRuntimeEntry.js +18 -7
- package/src/actions/xcodeProject.js +152 -0
- package/src/assets/cpp-runtime/node.cpp +18 -1
- package/src/assets/js-runtime/adapters/worker-comlink.js +58 -0
- package/src/assets/js-runtime/core.js +5 -4
- package/src/assets/toolchain-digests.json +25 -19
- package/src/assets/wasi-runtime/http/README.md +17 -0
- package/src/assets/wasi-runtime/http/bindings/crossbind_http.c +2537 -0
- package/src/assets/wasi-runtime/http/bindings/crossbind_http.h +826 -0
- package/src/assets/wasi-runtime/http/bindings/crossbind_http_component_type.o +0 -0
- package/src/assets/wasi-runtime/http/handler.cpp +298 -0
- package/src/assets/wasi-runtime/http/include/crossbind/http.h +31 -0
- package/src/assets/wasi-runtime/http/wit/deps/LICENSE.md +8 -0
- package/src/assets/wasi-runtime/http/wit/deps/cli.wit +28 -0
- package/src/assets/wasi-runtime/http/wit/deps/clocks.wit +43 -0
- package/src/assets/wasi-runtime/http/wit/deps/http.wit +509 -0
- package/src/assets/wasi-runtime/http/wit/deps/random.wit +18 -0
- package/src/assets/wasi-runtime/http/wit/world.wit +6 -0
- package/src/bin.js +102 -209
- package/src/cli.js +14 -0
- package/src/index.js +6 -0
- package/src/integration/getCrossbindScript.js +19 -4
- package/src/program.js +169 -0
- package/src/state/index.js +8 -3
- package/src/state/loadConfig.js +6 -11
- package/src/utils/appRustCrates.js +7 -1
- package/src/utils/bridgeExtras.js +74 -6
- package/src/utils/cargoLock.js +19 -0
- package/src/utils/cppDts.js +2 -0
- package/src/utils/downloadAndExtractFile.js +42 -14
- package/src/utils/embindObjectLifetime.js +35 -0
- package/src/utils/embindRsFingerprint.js +10 -3
- package/src/utils/hermes.js +40 -0
- package/src/utils/packageLicense.js +4 -2
- package/src/utils/plist.js +42 -0
- package/src/utils/pullDockerImage.js +9 -3
- package/src/utils/replaceBasePathForDocker.js +8 -0
- package/src/utils/resetCMakeCacheForSource.js +26 -0
- package/src/utils/resolveAppHost.js +21 -0
- package/src/utils/rustBridgeGen.js +13 -4
- package/src/utils/rustMt.js +5 -0
- package/src/utils/rustSysroot.js +7 -5
- package/src/utils/selectRunner.js +1 -1
- package/src/utils/swigInterface.js +5 -4
- package/src/utils/systemConfig.js +13 -0
- package/src/utils/systemKeys.js +4 -0
- package/src/utils/targets.js +30 -3
- package/src/utils/wasiHttp.js +50 -0
- package/vitest.config.js +5 -0
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
// Generated by `wit-bindgen` 0.62.0. DO NOT EDIT!
|
|
2
|
+
#ifndef __BINDINGS_CROSSBIND_HTTP_H
|
|
3
|
+
#define __BINDINGS_CROSSBIND_HTTP_H
|
|
4
|
+
#ifdef __cplusplus
|
|
5
|
+
extern "C" {
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
#include <stdbool.h>
|
|
10
|
+
#include <stddef.h>
|
|
11
|
+
|
|
12
|
+
typedef struct crossbind_http_string_t {
|
|
13
|
+
uint8_t*ptr;
|
|
14
|
+
size_t len;
|
|
15
|
+
} crossbind_http_string_t;
|
|
16
|
+
|
|
17
|
+
// Async Helper Functions
|
|
18
|
+
|
|
19
|
+
typedef uint32_t crossbind_http_subtask_status_t;
|
|
20
|
+
typedef uint32_t crossbind_http_subtask_t;
|
|
21
|
+
#define CROSSBIND_HTTP_SUBTASK_STATE(status) ((crossbind_http_subtask_state_t) ((status) & 0xf))
|
|
22
|
+
#define CROSSBIND_HTTP_SUBTASK_HANDLE(status) ((crossbind_http_subtask_t) ((status) >> 4))
|
|
23
|
+
|
|
24
|
+
typedef enum crossbind_http_subtask_state {
|
|
25
|
+
CROSSBIND_HTTP_SUBTASK_STARTING,
|
|
26
|
+
CROSSBIND_HTTP_SUBTASK_STARTED,
|
|
27
|
+
CROSSBIND_HTTP_SUBTASK_RETURNED,
|
|
28
|
+
CROSSBIND_HTTP_SUBTASK_STARTED_CANCELLED,
|
|
29
|
+
CROSSBIND_HTTP_SUBTASK_RETURNED_CANCELLED,
|
|
30
|
+
} crossbind_http_subtask_state_t;
|
|
31
|
+
|
|
32
|
+
crossbind_http_subtask_status_t crossbind_http_subtask_cancel(crossbind_http_subtask_t subtask);
|
|
33
|
+
void crossbind_http_subtask_drop(crossbind_http_subtask_t subtask);
|
|
34
|
+
|
|
35
|
+
typedef uint32_t crossbind_http_callback_code_t;
|
|
36
|
+
#define CROSSBIND_HTTP_CALLBACK_CODE_EXIT 0
|
|
37
|
+
#define CROSSBIND_HTTP_CALLBACK_CODE_YIELD 1
|
|
38
|
+
#define CROSSBIND_HTTP_CALLBACK_CODE_WAIT(set) (2 | (set << 4))
|
|
39
|
+
|
|
40
|
+
typedef enum crossbind_http_event_code {
|
|
41
|
+
CROSSBIND_HTTP_EVENT_NONE,
|
|
42
|
+
CROSSBIND_HTTP_EVENT_SUBTASK,
|
|
43
|
+
CROSSBIND_HTTP_EVENT_STREAM_READ,
|
|
44
|
+
CROSSBIND_HTTP_EVENT_STREAM_WRITE,
|
|
45
|
+
CROSSBIND_HTTP_EVENT_FUTURE_READ,
|
|
46
|
+
CROSSBIND_HTTP_EVENT_FUTURE_WRITE,
|
|
47
|
+
CROSSBIND_HTTP_EVENT_CANCEL,
|
|
48
|
+
} crossbind_http_event_code_t;
|
|
49
|
+
|
|
50
|
+
typedef struct crossbind_http_event {
|
|
51
|
+
crossbind_http_event_code_t event;
|
|
52
|
+
uint32_t waitable;
|
|
53
|
+
uint32_t code;
|
|
54
|
+
} crossbind_http_event_t;
|
|
55
|
+
|
|
56
|
+
typedef uint32_t crossbind_http_waitable_set_t;
|
|
57
|
+
crossbind_http_waitable_set_t crossbind_http_waitable_set_new(void);
|
|
58
|
+
void crossbind_http_waitable_join(uint32_t waitable, crossbind_http_waitable_set_t set);
|
|
59
|
+
void crossbind_http_waitable_set_drop(crossbind_http_waitable_set_t set);
|
|
60
|
+
void crossbind_http_waitable_set_wait(crossbind_http_waitable_set_t set, crossbind_http_event_t *event);
|
|
61
|
+
void crossbind_http_waitable_set_poll(crossbind_http_waitable_set_t set, crossbind_http_event_t *event);
|
|
62
|
+
|
|
63
|
+
void crossbind_http_task_cancel(void);
|
|
64
|
+
|
|
65
|
+
typedef uint32_t crossbind_http_waitable_status_t;
|
|
66
|
+
#define CROSSBIND_HTTP_WAITABLE_STATE(status) ((crossbind_http_waitable_state_t) ((status) & 0xf))
|
|
67
|
+
#define CROSSBIND_HTTP_WAITABLE_COUNT(status) ((uint32_t) ((status) >> 4))
|
|
68
|
+
#define CROSSBIND_HTTP_WAITABLE_STATUS_BLOCKED ((crossbind_http_waitable_status_t) -1)
|
|
69
|
+
|
|
70
|
+
typedef enum crossbind_http_waitable_state {
|
|
71
|
+
CROSSBIND_HTTP_WAITABLE_COMPLETED,
|
|
72
|
+
CROSSBIND_HTTP_WAITABLE_DROPPED,
|
|
73
|
+
CROSSBIND_HTTP_WAITABLE_CANCELLED,
|
|
74
|
+
} crossbind_http_waitable_state_t;
|
|
75
|
+
|
|
76
|
+
void crossbind_http_backpressure_inc(void);
|
|
77
|
+
void crossbind_http_backpressure_dec(void);
|
|
78
|
+
void* crossbind_http_context_get_0(void);
|
|
79
|
+
void crossbind_http_context_set_0(void* value);
|
|
80
|
+
void crossbind_http_thread_yield(void);
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
typedef uint64_t wasi_clocks_types_duration_t;
|
|
85
|
+
|
|
86
|
+
typedef wasi_clocks_types_duration_t wasi_http_types_duration_t;
|
|
87
|
+
|
|
88
|
+
// This type corresponds to HTTP standard Methods.
|
|
89
|
+
typedef struct wasi_http_types_method_t {
|
|
90
|
+
uint8_t tag;
|
|
91
|
+
union {
|
|
92
|
+
crossbind_http_string_t other;
|
|
93
|
+
} val;
|
|
94
|
+
} wasi_http_types_method_t;
|
|
95
|
+
|
|
96
|
+
#define WASI_HTTP_TYPES_METHOD_GET 0
|
|
97
|
+
#define WASI_HTTP_TYPES_METHOD_HEAD 1
|
|
98
|
+
#define WASI_HTTP_TYPES_METHOD_POST 2
|
|
99
|
+
#define WASI_HTTP_TYPES_METHOD_PUT 3
|
|
100
|
+
#define WASI_HTTP_TYPES_METHOD_DELETE 4
|
|
101
|
+
#define WASI_HTTP_TYPES_METHOD_CONNECT 5
|
|
102
|
+
#define WASI_HTTP_TYPES_METHOD_OPTIONS 6
|
|
103
|
+
#define WASI_HTTP_TYPES_METHOD_TRACE 7
|
|
104
|
+
#define WASI_HTTP_TYPES_METHOD_PATCH 8
|
|
105
|
+
#define WASI_HTTP_TYPES_METHOD_OTHER 9
|
|
106
|
+
|
|
107
|
+
// This type corresponds to HTTP standard Related Schemes.
|
|
108
|
+
typedef struct wasi_http_types_scheme_t {
|
|
109
|
+
uint8_t tag;
|
|
110
|
+
union {
|
|
111
|
+
crossbind_http_string_t other;
|
|
112
|
+
} val;
|
|
113
|
+
} wasi_http_types_scheme_t;
|
|
114
|
+
|
|
115
|
+
#define WASI_HTTP_TYPES_SCHEME_HTTP 0
|
|
116
|
+
#define WASI_HTTP_TYPES_SCHEME_HTTPS 1
|
|
117
|
+
#define WASI_HTTP_TYPES_SCHEME_OTHER 2
|
|
118
|
+
|
|
119
|
+
typedef struct {
|
|
120
|
+
bool is_some;
|
|
121
|
+
crossbind_http_string_t val;
|
|
122
|
+
} crossbind_http_option_string_t;
|
|
123
|
+
|
|
124
|
+
typedef struct {
|
|
125
|
+
bool is_some;
|
|
126
|
+
uint16_t val;
|
|
127
|
+
} crossbind_http_option_u16_t;
|
|
128
|
+
|
|
129
|
+
// Defines the case payload type for `DNS-error` above:
|
|
130
|
+
typedef struct wasi_http_types_dns_error_payload_t {
|
|
131
|
+
crossbind_http_option_string_t rcode;
|
|
132
|
+
crossbind_http_option_u16_t info_code;
|
|
133
|
+
} wasi_http_types_dns_error_payload_t;
|
|
134
|
+
|
|
135
|
+
typedef struct {
|
|
136
|
+
bool is_some;
|
|
137
|
+
uint8_t val;
|
|
138
|
+
} crossbind_http_option_u8_t;
|
|
139
|
+
|
|
140
|
+
// Defines the case payload type for `TLS-alert-received` above:
|
|
141
|
+
typedef struct wasi_http_types_tls_alert_received_payload_t {
|
|
142
|
+
crossbind_http_option_u8_t alert_id;
|
|
143
|
+
crossbind_http_option_string_t alert_message;
|
|
144
|
+
} wasi_http_types_tls_alert_received_payload_t;
|
|
145
|
+
|
|
146
|
+
typedef struct {
|
|
147
|
+
bool is_some;
|
|
148
|
+
uint32_t val;
|
|
149
|
+
} crossbind_http_option_u32_t;
|
|
150
|
+
|
|
151
|
+
// Defines the case payload type for `HTTP-response-{header,trailer}-size` above:
|
|
152
|
+
typedef struct wasi_http_types_field_size_payload_t {
|
|
153
|
+
crossbind_http_option_string_t field_name;
|
|
154
|
+
crossbind_http_option_u32_t field_size;
|
|
155
|
+
} wasi_http_types_field_size_payload_t;
|
|
156
|
+
|
|
157
|
+
typedef struct {
|
|
158
|
+
bool is_some;
|
|
159
|
+
uint64_t val;
|
|
160
|
+
} crossbind_http_option_u64_t;
|
|
161
|
+
|
|
162
|
+
typedef struct {
|
|
163
|
+
bool is_some;
|
|
164
|
+
wasi_http_types_field_size_payload_t val;
|
|
165
|
+
} wasi_http_types_option_field_size_payload_t;
|
|
166
|
+
|
|
167
|
+
// These cases are inspired by the IANA HTTP Proxy Error Types:
|
|
168
|
+
// <https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types>
|
|
169
|
+
typedef struct wasi_http_types_error_code_t {
|
|
170
|
+
uint8_t tag;
|
|
171
|
+
union {
|
|
172
|
+
wasi_http_types_dns_error_payload_t dns_error;
|
|
173
|
+
wasi_http_types_tls_alert_received_payload_t tls_alert_received;
|
|
174
|
+
crossbind_http_option_u64_t http_request_body_size;
|
|
175
|
+
crossbind_http_option_u32_t http_request_header_section_size;
|
|
176
|
+
wasi_http_types_option_field_size_payload_t http_request_header_size;
|
|
177
|
+
crossbind_http_option_u32_t http_request_trailer_section_size;
|
|
178
|
+
wasi_http_types_field_size_payload_t http_request_trailer_size;
|
|
179
|
+
crossbind_http_option_u32_t http_response_header_section_size;
|
|
180
|
+
wasi_http_types_field_size_payload_t http_response_header_size;
|
|
181
|
+
crossbind_http_option_u64_t http_response_body_size;
|
|
182
|
+
crossbind_http_option_u32_t http_response_trailer_section_size;
|
|
183
|
+
wasi_http_types_field_size_payload_t http_response_trailer_size;
|
|
184
|
+
crossbind_http_option_string_t http_response_transfer_coding;
|
|
185
|
+
crossbind_http_option_string_t http_response_content_coding;
|
|
186
|
+
crossbind_http_option_string_t internal_error;
|
|
187
|
+
} val;
|
|
188
|
+
} wasi_http_types_error_code_t;
|
|
189
|
+
|
|
190
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_DNS_TIMEOUT 0
|
|
191
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_DNS_ERROR 1
|
|
192
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_DESTINATION_NOT_FOUND 2
|
|
193
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_DESTINATION_UNAVAILABLE 3
|
|
194
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_DESTINATION_IP_PROHIBITED 4
|
|
195
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_DESTINATION_IP_UNROUTABLE 5
|
|
196
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_CONNECTION_REFUSED 6
|
|
197
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_CONNECTION_TERMINATED 7
|
|
198
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_CONNECTION_TIMEOUT 8
|
|
199
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_CONNECTION_READ_TIMEOUT 9
|
|
200
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_CONNECTION_WRITE_TIMEOUT 10
|
|
201
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_CONNECTION_LIMIT_REACHED 11
|
|
202
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_TLS_PROTOCOL_ERROR 12
|
|
203
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_TLS_CERTIFICATE_ERROR 13
|
|
204
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_TLS_ALERT_RECEIVED 14
|
|
205
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_DENIED 15
|
|
206
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_LENGTH_REQUIRED 16
|
|
207
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_BODY_SIZE 17
|
|
208
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_METHOD_INVALID 18
|
|
209
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_URI_INVALID 19
|
|
210
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_URI_TOO_LONG 20
|
|
211
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_HEADER_SECTION_SIZE 21
|
|
212
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_HEADER_SIZE 22
|
|
213
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_TRAILER_SECTION_SIZE 23
|
|
214
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_REQUEST_TRAILER_SIZE 24
|
|
215
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_INCOMPLETE 25
|
|
216
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_HEADER_SECTION_SIZE 26
|
|
217
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_HEADER_SIZE 27
|
|
218
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_BODY_SIZE 28
|
|
219
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_TRAILER_SECTION_SIZE 29
|
|
220
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_TRAILER_SIZE 30
|
|
221
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_TRANSFER_CODING 31
|
|
222
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_CONTENT_CODING 32
|
|
223
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_RESPONSE_TIMEOUT 33
|
|
224
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_UPGRADE_FAILED 34
|
|
225
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_HTTP_PROTOCOL_ERROR 35
|
|
226
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_LOOP_DETECTED 36
|
|
227
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_CONFIGURATION_ERROR 37
|
|
228
|
+
// This is a catch-all error for anything that doesn't fit cleanly into a
|
|
229
|
+
// more specific case. It also includes an optional string for an
|
|
230
|
+
// unstructured description of the error. Users should not depend on the
|
|
231
|
+
// string for diagnosing errors, as it's not required to be consistent
|
|
232
|
+
// between implementations.
|
|
233
|
+
#define WASI_HTTP_TYPES_ERROR_CODE_INTERNAL_ERROR 38
|
|
234
|
+
|
|
235
|
+
// This type enumerates the different kinds of errors that may occur when
|
|
236
|
+
// setting or appending to a `fields` resource.
|
|
237
|
+
typedef struct wasi_http_types_header_error_t {
|
|
238
|
+
uint8_t tag;
|
|
239
|
+
union {
|
|
240
|
+
crossbind_http_option_string_t other;
|
|
241
|
+
} val;
|
|
242
|
+
} wasi_http_types_header_error_t;
|
|
243
|
+
|
|
244
|
+
// This error indicates that a `field-name` or `field-value` was
|
|
245
|
+
// syntactically invalid when used with an operation that sets headers in a
|
|
246
|
+
// `fields`.
|
|
247
|
+
#define WASI_HTTP_TYPES_HEADER_ERROR_INVALID_SYNTAX 0
|
|
248
|
+
// This error indicates that a forbidden `field-name` was used when trying
|
|
249
|
+
// to set a header in a `fields`.
|
|
250
|
+
#define WASI_HTTP_TYPES_HEADER_ERROR_FORBIDDEN 1
|
|
251
|
+
// This error indicates that the operation on the `fields` was not
|
|
252
|
+
// permitted because the fields are immutable.
|
|
253
|
+
#define WASI_HTTP_TYPES_HEADER_ERROR_IMMUTABLE 2
|
|
254
|
+
// This error indicates that the operation would exceed an
|
|
255
|
+
// implementation-defined limit on field sizes. This may apply to
|
|
256
|
+
// an individual `field-value`, a single `field-name` plus all its
|
|
257
|
+
// values, or the total aggregate size of all fields.
|
|
258
|
+
#define WASI_HTTP_TYPES_HEADER_ERROR_SIZE_EXCEEDED 3
|
|
259
|
+
// This is a catch-all error for anything that doesn't fit cleanly into a
|
|
260
|
+
// more specific case. Implementations can use this to extend the error
|
|
261
|
+
// type without breaking existing code. It also includes an optional
|
|
262
|
+
// string for an unstructured description of the error. Users should not
|
|
263
|
+
// depend on the string for diagnosing errors, as it's not required to be
|
|
264
|
+
// consistent between implementations.
|
|
265
|
+
#define WASI_HTTP_TYPES_HEADER_ERROR_OTHER 4
|
|
266
|
+
|
|
267
|
+
// This type enumerates the different kinds of errors that may occur when
|
|
268
|
+
// setting fields of a `request-options` resource.
|
|
269
|
+
typedef struct wasi_http_types_request_options_error_t {
|
|
270
|
+
uint8_t tag;
|
|
271
|
+
union {
|
|
272
|
+
crossbind_http_option_string_t other;
|
|
273
|
+
} val;
|
|
274
|
+
} wasi_http_types_request_options_error_t;
|
|
275
|
+
|
|
276
|
+
// Indicates the specified field is not supported by this implementation.
|
|
277
|
+
#define WASI_HTTP_TYPES_REQUEST_OPTIONS_ERROR_NOT_SUPPORTED 0
|
|
278
|
+
// Indicates that the operation on the `request-options` was not permitted
|
|
279
|
+
// because it is immutable.
|
|
280
|
+
#define WASI_HTTP_TYPES_REQUEST_OPTIONS_ERROR_IMMUTABLE 1
|
|
281
|
+
// This is a catch-all error for anything that doesn't fit cleanly into a
|
|
282
|
+
// more specific case. Implementations can use this to extend the error
|
|
283
|
+
// type without breaking existing code. It also includes an optional
|
|
284
|
+
// string for an unstructured description of the error. Users should not
|
|
285
|
+
// depend on the string for diagnosing errors, as it's not required to be
|
|
286
|
+
// consistent between implementations.
|
|
287
|
+
#define WASI_HTTP_TYPES_REQUEST_OPTIONS_ERROR_OTHER 2
|
|
288
|
+
|
|
289
|
+
// Field names are always strings.
|
|
290
|
+
//
|
|
291
|
+
// Field names should always be treated as case insensitive by the `fields`
|
|
292
|
+
// resource for the purposes of equality checking.
|
|
293
|
+
typedef crossbind_http_string_t wasi_http_types_field_name_t;
|
|
294
|
+
|
|
295
|
+
// Field values should always be ASCII strings. However, in
|
|
296
|
+
// reality, HTTP implementations often have to interpret malformed values,
|
|
297
|
+
// so they are provided as a list of bytes.
|
|
298
|
+
typedef struct wasi_http_types_field_value_t {
|
|
299
|
+
uint8_t *ptr;
|
|
300
|
+
size_t len;
|
|
301
|
+
} wasi_http_types_field_value_t;
|
|
302
|
+
|
|
303
|
+
typedef struct wasi_http_types_own_fields_t {
|
|
304
|
+
int32_t __handle;
|
|
305
|
+
} wasi_http_types_own_fields_t;
|
|
306
|
+
|
|
307
|
+
typedef struct wasi_http_types_borrow_fields_t {
|
|
308
|
+
int32_t __handle;
|
|
309
|
+
} wasi_http_types_borrow_fields_t;
|
|
310
|
+
|
|
311
|
+
typedef struct wasi_http_types_own_request_t {
|
|
312
|
+
int32_t __handle;
|
|
313
|
+
} wasi_http_types_own_request_t;
|
|
314
|
+
|
|
315
|
+
typedef struct wasi_http_types_borrow_request_t {
|
|
316
|
+
int32_t __handle;
|
|
317
|
+
} wasi_http_types_borrow_request_t;
|
|
318
|
+
|
|
319
|
+
typedef struct wasi_http_types_own_request_options_t {
|
|
320
|
+
int32_t __handle;
|
|
321
|
+
} wasi_http_types_own_request_options_t;
|
|
322
|
+
|
|
323
|
+
typedef struct wasi_http_types_borrow_request_options_t {
|
|
324
|
+
int32_t __handle;
|
|
325
|
+
} wasi_http_types_borrow_request_options_t;
|
|
326
|
+
|
|
327
|
+
// This type corresponds to the HTTP standard Status Code.
|
|
328
|
+
typedef uint16_t wasi_http_types_status_code_t;
|
|
329
|
+
|
|
330
|
+
typedef struct wasi_http_types_own_response_t {
|
|
331
|
+
int32_t __handle;
|
|
332
|
+
} wasi_http_types_own_response_t;
|
|
333
|
+
|
|
334
|
+
typedef struct wasi_http_types_borrow_response_t {
|
|
335
|
+
int32_t __handle;
|
|
336
|
+
} wasi_http_types_borrow_response_t;
|
|
337
|
+
|
|
338
|
+
typedef struct {
|
|
339
|
+
wasi_http_types_field_name_t f0;
|
|
340
|
+
wasi_http_types_field_value_t f1;
|
|
341
|
+
} wasi_http_types_tuple2_field_name_field_value_t;
|
|
342
|
+
|
|
343
|
+
typedef struct {
|
|
344
|
+
wasi_http_types_tuple2_field_name_field_value_t *ptr;
|
|
345
|
+
size_t len;
|
|
346
|
+
} wasi_http_types_list_tuple2_field_name_field_value_t;
|
|
347
|
+
|
|
348
|
+
typedef struct {
|
|
349
|
+
bool is_err;
|
|
350
|
+
union {
|
|
351
|
+
wasi_http_types_own_fields_t ok;
|
|
352
|
+
wasi_http_types_header_error_t err;
|
|
353
|
+
} val;
|
|
354
|
+
} wasi_http_types_result_own_fields_header_error_t;
|
|
355
|
+
|
|
356
|
+
typedef struct {
|
|
357
|
+
wasi_http_types_field_value_t *ptr;
|
|
358
|
+
size_t len;
|
|
359
|
+
} wasi_http_types_list_field_value_t;
|
|
360
|
+
|
|
361
|
+
typedef struct {
|
|
362
|
+
bool is_err;
|
|
363
|
+
union {
|
|
364
|
+
wasi_http_types_header_error_t err;
|
|
365
|
+
} val;
|
|
366
|
+
} wasi_http_types_result_void_header_error_t;
|
|
367
|
+
|
|
368
|
+
typedef struct {
|
|
369
|
+
bool is_err;
|
|
370
|
+
union {
|
|
371
|
+
wasi_http_types_list_field_value_t ok;
|
|
372
|
+
wasi_http_types_header_error_t err;
|
|
373
|
+
} val;
|
|
374
|
+
} wasi_http_types_result_list_field_value_header_error_t;
|
|
375
|
+
|
|
376
|
+
typedef wasi_http_types_own_fields_t wasi_http_types_own_headers_t;
|
|
377
|
+
|
|
378
|
+
typedef uint32_t wasi_http_types_stream_u8_t;
|
|
379
|
+
|
|
380
|
+
typedef struct {
|
|
381
|
+
bool is_some;
|
|
382
|
+
wasi_http_types_stream_u8_t val;
|
|
383
|
+
} wasi_http_types_option_stream_u8_t;
|
|
384
|
+
|
|
385
|
+
typedef wasi_http_types_own_fields_t wasi_http_types_own_trailers_t;
|
|
386
|
+
|
|
387
|
+
typedef struct {
|
|
388
|
+
bool is_some;
|
|
389
|
+
wasi_http_types_own_trailers_t val;
|
|
390
|
+
} wasi_http_types_option_own_trailers_t;
|
|
391
|
+
|
|
392
|
+
typedef struct {
|
|
393
|
+
bool is_err;
|
|
394
|
+
union {
|
|
395
|
+
wasi_http_types_option_own_trailers_t ok;
|
|
396
|
+
wasi_http_types_error_code_t err;
|
|
397
|
+
} val;
|
|
398
|
+
} wasi_http_types_result_option_own_trailers_error_code_t;
|
|
399
|
+
|
|
400
|
+
typedef uint32_t wasi_http_types_future_result_option_own_trailers_error_code_t;
|
|
401
|
+
|
|
402
|
+
typedef struct {
|
|
403
|
+
bool is_some;
|
|
404
|
+
wasi_http_types_own_request_options_t val;
|
|
405
|
+
} wasi_http_types_option_own_request_options_t;
|
|
406
|
+
|
|
407
|
+
typedef struct {
|
|
408
|
+
bool is_err;
|
|
409
|
+
union {
|
|
410
|
+
wasi_http_types_error_code_t err;
|
|
411
|
+
} val;
|
|
412
|
+
} wasi_http_types_result_void_error_code_t;
|
|
413
|
+
|
|
414
|
+
typedef uint32_t wasi_http_types_future_result_void_error_code_t;
|
|
415
|
+
|
|
416
|
+
typedef struct {
|
|
417
|
+
wasi_http_types_own_request_t f0;
|
|
418
|
+
wasi_http_types_future_result_void_error_code_t f1;
|
|
419
|
+
} wasi_http_types_tuple2_own_request_future_result_void_error_code_t;
|
|
420
|
+
|
|
421
|
+
typedef struct {
|
|
422
|
+
bool is_err;
|
|
423
|
+
} wasi_http_types_result_void_void_t;
|
|
424
|
+
|
|
425
|
+
typedef struct {
|
|
426
|
+
bool is_some;
|
|
427
|
+
wasi_http_types_scheme_t val;
|
|
428
|
+
} wasi_http_types_option_scheme_t;
|
|
429
|
+
|
|
430
|
+
typedef struct {
|
|
431
|
+
wasi_http_types_stream_u8_t f0;
|
|
432
|
+
wasi_http_types_future_result_option_own_trailers_error_code_t f1;
|
|
433
|
+
} wasi_http_types_tuple2_stream_u8_future_result_option_own_trailers_error_code_t;
|
|
434
|
+
|
|
435
|
+
typedef struct {
|
|
436
|
+
bool is_some;
|
|
437
|
+
wasi_http_types_duration_t val;
|
|
438
|
+
} wasi_http_types_option_duration_t;
|
|
439
|
+
|
|
440
|
+
typedef struct {
|
|
441
|
+
bool is_err;
|
|
442
|
+
union {
|
|
443
|
+
wasi_http_types_request_options_error_t err;
|
|
444
|
+
} val;
|
|
445
|
+
} wasi_http_types_result_void_request_options_error_t;
|
|
446
|
+
|
|
447
|
+
typedef struct {
|
|
448
|
+
wasi_http_types_own_response_t f0;
|
|
449
|
+
wasi_http_types_future_result_void_error_code_t f1;
|
|
450
|
+
} wasi_http_types_tuple2_own_response_future_result_void_error_code_t;
|
|
451
|
+
|
|
452
|
+
typedef wasi_http_types_error_code_t exports_wasi_http_handler_error_code_t;
|
|
453
|
+
|
|
454
|
+
typedef wasi_http_types_own_request_t exports_wasi_http_handler_own_request_t;
|
|
455
|
+
|
|
456
|
+
typedef wasi_http_types_own_response_t exports_wasi_http_handler_own_response_t;
|
|
457
|
+
|
|
458
|
+
typedef struct {
|
|
459
|
+
bool is_err;
|
|
460
|
+
union {
|
|
461
|
+
exports_wasi_http_handler_own_response_t ok;
|
|
462
|
+
exports_wasi_http_handler_error_code_t err;
|
|
463
|
+
} val;
|
|
464
|
+
} exports_wasi_http_handler_result_own_response_error_code_t;
|
|
465
|
+
|
|
466
|
+
// Imported Functions from `wasi:http/types@0.3.0`
|
|
467
|
+
// Construct an empty HTTP Fields.
|
|
468
|
+
//
|
|
469
|
+
// The resulting `fields` is mutable.
|
|
470
|
+
extern wasi_http_types_own_fields_t wasi_http_types_constructor_fields(void);
|
|
471
|
+
// Construct an HTTP Fields.
|
|
472
|
+
//
|
|
473
|
+
// The resulting `fields` is mutable.
|
|
474
|
+
//
|
|
475
|
+
// The list represents each name-value pair in the Fields. Names
|
|
476
|
+
// which have multiple values are represented by multiple entries in this
|
|
477
|
+
// list with the same name.
|
|
478
|
+
//
|
|
479
|
+
// The tuple is a pair of the field name, represented as a string, and
|
|
480
|
+
// Value, represented as a list of bytes. In a valid Fields, all names
|
|
481
|
+
// and values are valid UTF-8 strings. However, values are not always
|
|
482
|
+
// well-formed, so they are represented as a raw list of bytes.
|
|
483
|
+
//
|
|
484
|
+
// An error result will be returned if any header or value was
|
|
485
|
+
// syntactically invalid, if a header was forbidden, or if the
|
|
486
|
+
// entries would exceed an implementation size limit.
|
|
487
|
+
extern bool wasi_http_types_static_fields_from_list(wasi_http_types_list_tuple2_field_name_field_value_t *entries, wasi_http_types_own_fields_t *ret, wasi_http_types_header_error_t *err);
|
|
488
|
+
// Get all of the values corresponding to a name. If the name is not present
|
|
489
|
+
// in this `fields`, an empty list is returned. However, if the name is
|
|
490
|
+
// present but empty, this is represented by a list with one or more
|
|
491
|
+
// empty field-values present.
|
|
492
|
+
extern void wasi_http_types_method_fields_get(wasi_http_types_borrow_fields_t self, wasi_http_types_field_name_t *name, wasi_http_types_list_field_value_t *ret);
|
|
493
|
+
// Returns `true` when the name is present in this `fields`. If the name is
|
|
494
|
+
// syntactically invalid, `false` is returned.
|
|
495
|
+
extern bool wasi_http_types_method_fields_has(wasi_http_types_borrow_fields_t self, wasi_http_types_field_name_t *name);
|
|
496
|
+
// Set all of the values for a name. Clears any existing values for that
|
|
497
|
+
// name, if they have been set.
|
|
498
|
+
//
|
|
499
|
+
// Fails with `header-error.immutable` if the `fields` are immutable.
|
|
500
|
+
//
|
|
501
|
+
// Fails with `header-error.size-exceeded` if the name or values would
|
|
502
|
+
// exceed an implementation-defined size limit.
|
|
503
|
+
extern bool wasi_http_types_method_fields_set(wasi_http_types_borrow_fields_t self, wasi_http_types_field_name_t *name, wasi_http_types_list_field_value_t *value, wasi_http_types_header_error_t *err);
|
|
504
|
+
// Delete all values for a name. Does nothing if no values for the name
|
|
505
|
+
// exist.
|
|
506
|
+
//
|
|
507
|
+
// Fails with `header-error.immutable` if the `fields` are immutable.
|
|
508
|
+
extern bool wasi_http_types_method_fields_delete(wasi_http_types_borrow_fields_t self, wasi_http_types_field_name_t *name, wasi_http_types_header_error_t *err);
|
|
509
|
+
// Delete all values for a name. Does nothing if no values for the name
|
|
510
|
+
// exist.
|
|
511
|
+
//
|
|
512
|
+
// Returns all values previously corresponding to the name, if any.
|
|
513
|
+
//
|
|
514
|
+
// Fails with `header-error.immutable` if the `fields` are immutable.
|
|
515
|
+
extern bool wasi_http_types_method_fields_get_and_delete(wasi_http_types_borrow_fields_t self, wasi_http_types_field_name_t *name, wasi_http_types_list_field_value_t *ret, wasi_http_types_header_error_t *err);
|
|
516
|
+
// Append a value for a name. Does not change or delete any existing
|
|
517
|
+
// values for that name.
|
|
518
|
+
//
|
|
519
|
+
// Fails with `header-error.immutable` if the `fields` are immutable.
|
|
520
|
+
//
|
|
521
|
+
// Fails with `header-error.size-exceeded` if the value would exceed
|
|
522
|
+
// an implementation-defined size limit.
|
|
523
|
+
extern bool wasi_http_types_method_fields_append(wasi_http_types_borrow_fields_t self, wasi_http_types_field_name_t *name, wasi_http_types_field_value_t *value, wasi_http_types_header_error_t *err);
|
|
524
|
+
// Retrieve the full set of names and values in the Fields. Like the
|
|
525
|
+
// constructor, the list represents each name-value pair.
|
|
526
|
+
//
|
|
527
|
+
// The outer list represents each name-value pair in the Fields. Names
|
|
528
|
+
// which have multiple values are represented by multiple entries in this
|
|
529
|
+
// list with the same name.
|
|
530
|
+
//
|
|
531
|
+
// The names and values are always returned in the original casing and in
|
|
532
|
+
// the order in which they will be serialized for transport.
|
|
533
|
+
extern void wasi_http_types_method_fields_copy_all(wasi_http_types_borrow_fields_t self, wasi_http_types_list_tuple2_field_name_field_value_t *ret);
|
|
534
|
+
// Make a deep copy of the Fields. Equivalent in behavior to calling the
|
|
535
|
+
// `fields` constructor on the return value of `copy-all`. The resulting
|
|
536
|
+
// `fields` is mutable.
|
|
537
|
+
extern wasi_http_types_own_fields_t wasi_http_types_method_fields_clone(wasi_http_types_borrow_fields_t self);
|
|
538
|
+
// Construct a new `request` with a default `method` of `GET`, and
|
|
539
|
+
// `none` values for `path-with-query`, `scheme`, and `authority`.
|
|
540
|
+
//
|
|
541
|
+
// `headers` is the HTTP Headers for the Request.
|
|
542
|
+
//
|
|
543
|
+
// `contents` is the optional body content stream with `none`
|
|
544
|
+
// representing a zero-length content stream.
|
|
545
|
+
// Once it is closed, `trailers` future must resolve to a result.
|
|
546
|
+
// If `trailers` resolves to an error, underlying connection
|
|
547
|
+
// will be closed immediately.
|
|
548
|
+
//
|
|
549
|
+
// `options` is optional `request-options` resource to be used
|
|
550
|
+
// if the request is sent over a network connection.
|
|
551
|
+
//
|
|
552
|
+
// It is possible to construct, or manipulate with the accessor functions
|
|
553
|
+
// below, a `request` with an invalid combination of `scheme`
|
|
554
|
+
// and `authority`, or `headers` which are not permitted to be sent.
|
|
555
|
+
// It is the obligation of the `handler.handle` implementation
|
|
556
|
+
// to reject invalid constructions of `request`.
|
|
557
|
+
//
|
|
558
|
+
// The returned future resolves to result of transmission of this request.
|
|
559
|
+
extern void wasi_http_types_static_request_new(wasi_http_types_own_headers_t headers, wasi_http_types_stream_u8_t *maybe_contents, wasi_http_types_future_result_option_own_trailers_error_code_t trailers, wasi_http_types_own_request_options_t *maybe_options, wasi_http_types_tuple2_own_request_future_result_void_error_code_t *ret);
|
|
560
|
+
// Get the Method for the Request.
|
|
561
|
+
extern void wasi_http_types_method_request_get_method(wasi_http_types_borrow_request_t self, wasi_http_types_method_t *ret);
|
|
562
|
+
// Set the Method for the Request. Fails if the string present in a
|
|
563
|
+
// `method.other` argument is not a syntactically valid method.
|
|
564
|
+
extern bool wasi_http_types_method_request_set_method(wasi_http_types_borrow_request_t self, wasi_http_types_method_t *method);
|
|
565
|
+
// Get the combination of the HTTP Path and Query for the Request. When
|
|
566
|
+
// `none`, this represents an empty Path and empty Query.
|
|
567
|
+
extern bool wasi_http_types_method_request_get_path_with_query(wasi_http_types_borrow_request_t self, crossbind_http_string_t *ret);
|
|
568
|
+
// Set the combination of the HTTP Path and Query for the Request. When
|
|
569
|
+
// `none`, this represents an empty Path and empty Query. Fails is the
|
|
570
|
+
// string given is not a syntactically valid path and query uri component.
|
|
571
|
+
extern bool wasi_http_types_method_request_set_path_with_query(wasi_http_types_borrow_request_t self, crossbind_http_string_t *maybe_path_with_query);
|
|
572
|
+
// Get the HTTP Related Scheme for the Request. When `none`, the
|
|
573
|
+
// implementation may choose an appropriate default scheme.
|
|
574
|
+
extern bool wasi_http_types_method_request_get_scheme(wasi_http_types_borrow_request_t self, wasi_http_types_scheme_t *ret);
|
|
575
|
+
// Set the HTTP Related Scheme for the Request. When `none`, the
|
|
576
|
+
// implementation may choose an appropriate default scheme. Fails if the
|
|
577
|
+
// string given is not a syntactically valid uri scheme.
|
|
578
|
+
extern bool wasi_http_types_method_request_set_scheme(wasi_http_types_borrow_request_t self, wasi_http_types_scheme_t *maybe_scheme);
|
|
579
|
+
// Get the authority of the Request's target URI. A value of `none` may be used
|
|
580
|
+
// with Related Schemes which do not require an authority. The HTTP and
|
|
581
|
+
// HTTPS schemes always require an authority.
|
|
582
|
+
extern bool wasi_http_types_method_request_get_authority(wasi_http_types_borrow_request_t self, crossbind_http_string_t *ret);
|
|
583
|
+
// Set the authority of the Request's target URI. A value of `none` may be used
|
|
584
|
+
// with Related Schemes which do not require an authority. The HTTP and
|
|
585
|
+
// HTTPS schemes always require an authority. Fails if the string given is
|
|
586
|
+
// not a syntactically valid URI authority.
|
|
587
|
+
extern bool wasi_http_types_method_request_set_authority(wasi_http_types_borrow_request_t self, crossbind_http_string_t *maybe_authority);
|
|
588
|
+
// Get the `request-options` to be associated with this request
|
|
589
|
+
//
|
|
590
|
+
// The returned `request-options` resource is immutable: `set-*` operations
|
|
591
|
+
// will fail if invoked.
|
|
592
|
+
//
|
|
593
|
+
// This `request-options` resource is a child: it must be dropped before
|
|
594
|
+
// the parent `request` is dropped, or its ownership is transferred to
|
|
595
|
+
// another component by e.g. `handler.handle`.
|
|
596
|
+
extern bool wasi_http_types_method_request_get_options(wasi_http_types_borrow_request_t self, wasi_http_types_own_request_options_t *ret);
|
|
597
|
+
// Get the headers associated with the Request.
|
|
598
|
+
//
|
|
599
|
+
// The returned `headers` resource is immutable: `set`, `append`, and
|
|
600
|
+
// `delete` operations will fail with `header-error.immutable`.
|
|
601
|
+
extern wasi_http_types_own_headers_t wasi_http_types_method_request_get_headers(wasi_http_types_borrow_request_t self);
|
|
602
|
+
// Get body of the Request.
|
|
603
|
+
//
|
|
604
|
+
// Stream returned by this method represents the contents of the body.
|
|
605
|
+
// Once the stream is reported as closed, callers should await the returned
|
|
606
|
+
// future to determine whether the body was received successfully.
|
|
607
|
+
// The future will only resolve after the stream is reported as closed.
|
|
608
|
+
//
|
|
609
|
+
// This function takes a `res` future as a parameter, which can be used to
|
|
610
|
+
// communicate an error in handling of the request.
|
|
611
|
+
//
|
|
612
|
+
// Note that function will move the `request`, but references to headers or
|
|
613
|
+
// request options acquired from it previously will remain valid.
|
|
614
|
+
extern void wasi_http_types_static_request_consume_body(wasi_http_types_own_request_t this_, wasi_http_types_future_result_void_error_code_t res, wasi_http_types_tuple2_stream_u8_future_result_option_own_trailers_error_code_t *ret);
|
|
615
|
+
// Construct a default `request-options` value.
|
|
616
|
+
extern wasi_http_types_own_request_options_t wasi_http_types_constructor_request_options(void);
|
|
617
|
+
// The timeout for the initial connect to the HTTP Server.
|
|
618
|
+
extern bool wasi_http_types_method_request_options_get_connect_timeout(wasi_http_types_borrow_request_options_t self, wasi_http_types_duration_t *ret);
|
|
619
|
+
// Set the timeout for the initial connect to the HTTP Server. An error
|
|
620
|
+
// return value indicates that this timeout is not supported or that this
|
|
621
|
+
// handle is immutable.
|
|
622
|
+
extern bool wasi_http_types_method_request_options_set_connect_timeout(wasi_http_types_borrow_request_options_t self, wasi_http_types_duration_t *maybe_duration, wasi_http_types_request_options_error_t *err);
|
|
623
|
+
// The timeout for receiving the first byte of the Response body.
|
|
624
|
+
extern bool wasi_http_types_method_request_options_get_first_byte_timeout(wasi_http_types_borrow_request_options_t self, wasi_http_types_duration_t *ret);
|
|
625
|
+
// Set the timeout for receiving the first byte of the Response body. An
|
|
626
|
+
// error return value indicates that this timeout is not supported or that
|
|
627
|
+
// this handle is immutable.
|
|
628
|
+
extern bool wasi_http_types_method_request_options_set_first_byte_timeout(wasi_http_types_borrow_request_options_t self, wasi_http_types_duration_t *maybe_duration, wasi_http_types_request_options_error_t *err);
|
|
629
|
+
// The timeout for receiving subsequent chunks of bytes in the Response
|
|
630
|
+
// body stream.
|
|
631
|
+
extern bool wasi_http_types_method_request_options_get_between_bytes_timeout(wasi_http_types_borrow_request_options_t self, wasi_http_types_duration_t *ret);
|
|
632
|
+
// Set the timeout for receiving subsequent chunks of bytes in the Response
|
|
633
|
+
// body stream. An error return value indicates that this timeout is not
|
|
634
|
+
// supported or that this handle is immutable.
|
|
635
|
+
extern bool wasi_http_types_method_request_options_set_between_bytes_timeout(wasi_http_types_borrow_request_options_t self, wasi_http_types_duration_t *maybe_duration, wasi_http_types_request_options_error_t *err);
|
|
636
|
+
// Make a deep copy of the `request-options`.
|
|
637
|
+
// The resulting `request-options` is mutable.
|
|
638
|
+
extern wasi_http_types_own_request_options_t wasi_http_types_method_request_options_clone(wasi_http_types_borrow_request_options_t self);
|
|
639
|
+
// Construct a new `response`, with a default `status-code` of `200`.
|
|
640
|
+
// If a different `status-code` is needed, it must be set via the
|
|
641
|
+
// `set-status-code` method.
|
|
642
|
+
//
|
|
643
|
+
// `headers` is the HTTP Headers for the Response.
|
|
644
|
+
//
|
|
645
|
+
// `contents` is the optional body content stream with `none`
|
|
646
|
+
// representing a zero-length content stream.
|
|
647
|
+
// Once it is closed, `trailers` future must resolve to a result.
|
|
648
|
+
// If `trailers` resolves to an error, underlying connection
|
|
649
|
+
// will be closed immediately.
|
|
650
|
+
//
|
|
651
|
+
// The returned future resolves to result of transmission of this response.
|
|
652
|
+
extern void wasi_http_types_static_response_new(wasi_http_types_own_headers_t headers, wasi_http_types_stream_u8_t *maybe_contents, wasi_http_types_future_result_option_own_trailers_error_code_t trailers, wasi_http_types_tuple2_own_response_future_result_void_error_code_t *ret);
|
|
653
|
+
// Get the HTTP Status Code for the Response.
|
|
654
|
+
extern wasi_http_types_status_code_t wasi_http_types_method_response_get_status_code(wasi_http_types_borrow_response_t self);
|
|
655
|
+
// Set the HTTP Status Code for the Response. Fails if the status-code
|
|
656
|
+
// given is not a valid http status code.
|
|
657
|
+
extern bool wasi_http_types_method_response_set_status_code(wasi_http_types_borrow_response_t self, wasi_http_types_status_code_t status_code);
|
|
658
|
+
// Get the headers associated with the Response.
|
|
659
|
+
//
|
|
660
|
+
// The returned `headers` resource is immutable: `set`, `append`, and
|
|
661
|
+
// `delete` operations will fail with `header-error.immutable`.
|
|
662
|
+
extern wasi_http_types_own_headers_t wasi_http_types_method_response_get_headers(wasi_http_types_borrow_response_t self);
|
|
663
|
+
// Get body of the Response.
|
|
664
|
+
//
|
|
665
|
+
// Stream returned by this method represents the contents of the body.
|
|
666
|
+
// Once the stream is reported as closed, callers should await the returned
|
|
667
|
+
// future to determine whether the body was received successfully.
|
|
668
|
+
// The future will only resolve after the stream is reported as closed.
|
|
669
|
+
//
|
|
670
|
+
// This function takes a `res` future as a parameter, which can be used to
|
|
671
|
+
// communicate an error in handling of the response.
|
|
672
|
+
//
|
|
673
|
+
// Note that function will move the `response`, but references to headers
|
|
674
|
+
// acquired from it previously will remain valid.
|
|
675
|
+
extern void wasi_http_types_static_response_consume_body(wasi_http_types_own_response_t this_, wasi_http_types_future_result_void_error_code_t res, wasi_http_types_tuple2_stream_u8_future_result_option_own_trailers_error_code_t *ret);
|
|
676
|
+
|
|
677
|
+
// Exported Functions from `wasi:http/handler@0.3.0`
|
|
678
|
+
crossbind_http_callback_code_t exports_wasi_http_handler_handle(exports_wasi_http_handler_own_request_t request);
|
|
679
|
+
crossbind_http_callback_code_t exports_wasi_http_handler_handle_callback(crossbind_http_event_t *event);
|
|
680
|
+
|
|
681
|
+
// Helper Functions
|
|
682
|
+
|
|
683
|
+
void wasi_http_types_method_free(wasi_http_types_method_t *ptr);
|
|
684
|
+
|
|
685
|
+
void wasi_http_types_scheme_free(wasi_http_types_scheme_t *ptr);
|
|
686
|
+
|
|
687
|
+
void crossbind_http_option_string_free(crossbind_http_option_string_t *ptr);
|
|
688
|
+
|
|
689
|
+
void crossbind_http_option_u16_free(crossbind_http_option_u16_t *ptr);
|
|
690
|
+
|
|
691
|
+
void wasi_http_types_dns_error_payload_free(wasi_http_types_dns_error_payload_t *ptr);
|
|
692
|
+
|
|
693
|
+
void crossbind_http_option_u8_free(crossbind_http_option_u8_t *ptr);
|
|
694
|
+
|
|
695
|
+
void wasi_http_types_tls_alert_received_payload_free(wasi_http_types_tls_alert_received_payload_t *ptr);
|
|
696
|
+
|
|
697
|
+
void crossbind_http_option_u32_free(crossbind_http_option_u32_t *ptr);
|
|
698
|
+
|
|
699
|
+
void wasi_http_types_field_size_payload_free(wasi_http_types_field_size_payload_t *ptr);
|
|
700
|
+
|
|
701
|
+
void crossbind_http_option_u64_free(crossbind_http_option_u64_t *ptr);
|
|
702
|
+
|
|
703
|
+
void wasi_http_types_option_field_size_payload_free(wasi_http_types_option_field_size_payload_t *ptr);
|
|
704
|
+
|
|
705
|
+
void wasi_http_types_error_code_free(wasi_http_types_error_code_t *ptr);
|
|
706
|
+
|
|
707
|
+
void wasi_http_types_header_error_free(wasi_http_types_header_error_t *ptr);
|
|
708
|
+
|
|
709
|
+
void wasi_http_types_request_options_error_free(wasi_http_types_request_options_error_t *ptr);
|
|
710
|
+
|
|
711
|
+
void wasi_http_types_field_name_free(wasi_http_types_field_name_t *ptr);
|
|
712
|
+
|
|
713
|
+
void wasi_http_types_field_value_free(wasi_http_types_field_value_t *ptr);
|
|
714
|
+
|
|
715
|
+
extern void wasi_http_types_fields_drop_own(wasi_http_types_own_fields_t handle);
|
|
716
|
+
|
|
717
|
+
extern void wasi_http_types_fields_drop_borrow(wasi_http_types_borrow_fields_t handle);
|
|
718
|
+
|
|
719
|
+
extern wasi_http_types_borrow_fields_t wasi_http_types_borrow_fields(wasi_http_types_own_fields_t handle);
|
|
720
|
+
|
|
721
|
+
extern void wasi_http_types_request_drop_own(wasi_http_types_own_request_t handle);
|
|
722
|
+
|
|
723
|
+
extern void wasi_http_types_request_drop_borrow(wasi_http_types_borrow_request_t handle);
|
|
724
|
+
|
|
725
|
+
extern wasi_http_types_borrow_request_t wasi_http_types_borrow_request(wasi_http_types_own_request_t handle);
|
|
726
|
+
|
|
727
|
+
extern void wasi_http_types_request_options_drop_own(wasi_http_types_own_request_options_t handle);
|
|
728
|
+
|
|
729
|
+
extern void wasi_http_types_request_options_drop_borrow(wasi_http_types_borrow_request_options_t handle);
|
|
730
|
+
|
|
731
|
+
extern wasi_http_types_borrow_request_options_t wasi_http_types_borrow_request_options(wasi_http_types_own_request_options_t handle);
|
|
732
|
+
|
|
733
|
+
extern void wasi_http_types_response_drop_own(wasi_http_types_own_response_t handle);
|
|
734
|
+
|
|
735
|
+
extern void wasi_http_types_response_drop_borrow(wasi_http_types_borrow_response_t handle);
|
|
736
|
+
|
|
737
|
+
extern wasi_http_types_borrow_response_t wasi_http_types_borrow_response(wasi_http_types_own_response_t handle);
|
|
738
|
+
|
|
739
|
+
void wasi_http_types_tuple2_field_name_field_value_free(wasi_http_types_tuple2_field_name_field_value_t *ptr);
|
|
740
|
+
|
|
741
|
+
void wasi_http_types_list_tuple2_field_name_field_value_free(wasi_http_types_list_tuple2_field_name_field_value_t *ptr);
|
|
742
|
+
|
|
743
|
+
void wasi_http_types_result_own_fields_header_error_free(wasi_http_types_result_own_fields_header_error_t *ptr);
|
|
744
|
+
|
|
745
|
+
void wasi_http_types_list_field_value_free(wasi_http_types_list_field_value_t *ptr);
|
|
746
|
+
|
|
747
|
+
void wasi_http_types_result_void_header_error_free(wasi_http_types_result_void_header_error_t *ptr);
|
|
748
|
+
|
|
749
|
+
void wasi_http_types_result_list_field_value_header_error_free(wasi_http_types_result_list_field_value_header_error_t *ptr);
|
|
750
|
+
|
|
751
|
+
void wasi_http_types_option_stream_u8_free(wasi_http_types_option_stream_u8_t *ptr);
|
|
752
|
+
|
|
753
|
+
void wasi_http_types_option_own_trailers_free(wasi_http_types_option_own_trailers_t *ptr);
|
|
754
|
+
|
|
755
|
+
void wasi_http_types_result_option_own_trailers_error_code_free(wasi_http_types_result_option_own_trailers_error_code_t *ptr);
|
|
756
|
+
|
|
757
|
+
void wasi_http_types_option_own_request_options_free(wasi_http_types_option_own_request_options_t *ptr);
|
|
758
|
+
|
|
759
|
+
void wasi_http_types_result_void_error_code_free(wasi_http_types_result_void_error_code_t *ptr);
|
|
760
|
+
|
|
761
|
+
void wasi_http_types_result_void_void_free(wasi_http_types_result_void_void_t *ptr);
|
|
762
|
+
|
|
763
|
+
void wasi_http_types_option_scheme_free(wasi_http_types_option_scheme_t *ptr);
|
|
764
|
+
|
|
765
|
+
void wasi_http_types_option_duration_free(wasi_http_types_option_duration_t *ptr);
|
|
766
|
+
|
|
767
|
+
void wasi_http_types_result_void_request_options_error_free(wasi_http_types_result_void_request_options_error_t *ptr);
|
|
768
|
+
|
|
769
|
+
typedef uint32_t wasi_http_types_stream_u8_writer_t;
|
|
770
|
+
|
|
771
|
+
wasi_http_types_stream_u8_t wasi_http_types_stream_u8_new(wasi_http_types_stream_u8_writer_t *writer);
|
|
772
|
+
crossbind_http_waitable_status_t wasi_http_types_stream_u8_read(wasi_http_types_stream_u8_t reader, uint8_t *buf, size_t amt);
|
|
773
|
+
crossbind_http_waitable_status_t wasi_http_types_stream_u8_write(wasi_http_types_stream_u8_writer_t writer, const uint8_t *buf, size_t amt);
|
|
774
|
+
crossbind_http_waitable_status_t wasi_http_types_stream_u8_cancel_read(wasi_http_types_stream_u8_t reader);
|
|
775
|
+
crossbind_http_waitable_status_t wasi_http_types_stream_u8_cancel_write(wasi_http_types_stream_u8_writer_t writer);
|
|
776
|
+
void wasi_http_types_stream_u8_drop_readable(wasi_http_types_stream_u8_t reader);
|
|
777
|
+
void wasi_http_types_stream_u8_drop_writable(wasi_http_types_stream_u8_writer_t writer);
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
typedef uint32_t wasi_http_types_future_result_option_own_trailers_error_code_writer_t;
|
|
781
|
+
|
|
782
|
+
wasi_http_types_future_result_option_own_trailers_error_code_t wasi_http_types_future_result_option_own_trailers_error_code_new(wasi_http_types_future_result_option_own_trailers_error_code_writer_t *writer);
|
|
783
|
+
crossbind_http_waitable_status_t wasi_http_types_future_result_option_own_trailers_error_code_read(wasi_http_types_future_result_option_own_trailers_error_code_t reader, wasi_http_types_result_option_own_trailers_error_code_t *buf);
|
|
784
|
+
crossbind_http_waitable_status_t wasi_http_types_future_result_option_own_trailers_error_code_write(wasi_http_types_future_result_option_own_trailers_error_code_writer_t writer, const wasi_http_types_result_option_own_trailers_error_code_t *buf);
|
|
785
|
+
crossbind_http_waitable_status_t wasi_http_types_future_result_option_own_trailers_error_code_cancel_read(wasi_http_types_future_result_option_own_trailers_error_code_t reader);
|
|
786
|
+
crossbind_http_waitable_status_t wasi_http_types_future_result_option_own_trailers_error_code_cancel_write(wasi_http_types_future_result_option_own_trailers_error_code_writer_t writer);
|
|
787
|
+
void wasi_http_types_future_result_option_own_trailers_error_code_drop_readable(wasi_http_types_future_result_option_own_trailers_error_code_t reader);
|
|
788
|
+
void wasi_http_types_future_result_option_own_trailers_error_code_drop_writable(wasi_http_types_future_result_option_own_trailers_error_code_writer_t writer);
|
|
789
|
+
|
|
790
|
+
|
|
791
|
+
typedef uint32_t wasi_http_types_future_result_void_error_code_writer_t;
|
|
792
|
+
|
|
793
|
+
wasi_http_types_future_result_void_error_code_t wasi_http_types_future_result_void_error_code_new(wasi_http_types_future_result_void_error_code_writer_t *writer);
|
|
794
|
+
crossbind_http_waitable_status_t wasi_http_types_future_result_void_error_code_read(wasi_http_types_future_result_void_error_code_t reader, wasi_http_types_result_void_error_code_t *buf);
|
|
795
|
+
crossbind_http_waitable_status_t wasi_http_types_future_result_void_error_code_write(wasi_http_types_future_result_void_error_code_writer_t writer, const wasi_http_types_result_void_error_code_t *buf);
|
|
796
|
+
crossbind_http_waitable_status_t wasi_http_types_future_result_void_error_code_cancel_read(wasi_http_types_future_result_void_error_code_t reader);
|
|
797
|
+
crossbind_http_waitable_status_t wasi_http_types_future_result_void_error_code_cancel_write(wasi_http_types_future_result_void_error_code_writer_t writer);
|
|
798
|
+
void wasi_http_types_future_result_void_error_code_drop_readable(wasi_http_types_future_result_void_error_code_t reader);
|
|
799
|
+
void wasi_http_types_future_result_void_error_code_drop_writable(wasi_http_types_future_result_void_error_code_writer_t writer);
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
void exports_wasi_http_handler_error_code_free(exports_wasi_http_handler_error_code_t *ptr);
|
|
803
|
+
|
|
804
|
+
void exports_wasi_http_handler_result_own_response_error_code_free(exports_wasi_http_handler_result_own_response_error_code_t *ptr);
|
|
805
|
+
void exports_wasi_http_handler_handle_return(exports_wasi_http_handler_result_own_response_error_code_t ret);
|
|
806
|
+
|
|
807
|
+
// Sets the string `ret` to reference the input string `s` without copying it
|
|
808
|
+
void crossbind_http_string_set(crossbind_http_string_t *ret, const char*s);
|
|
809
|
+
|
|
810
|
+
// Creates a copy of the input nul-terminated string `s` and
|
|
811
|
+
// stores it into the component model string `ret`.
|
|
812
|
+
void crossbind_http_string_dup(crossbind_http_string_t *ret, const char*s);
|
|
813
|
+
|
|
814
|
+
// Creates a copy of the input string `s` with length `len` and
|
|
815
|
+
// stores it into the component model string `ret`.
|
|
816
|
+
// The length is specified in code units (bytes for UTF-8, 16-bit values for UTF-16).
|
|
817
|
+
void crossbind_http_string_dup_n(crossbind_http_string_t *ret, const char*s, size_t len);
|
|
818
|
+
|
|
819
|
+
// Deallocates the string pointed to by `ret`, deallocating
|
|
820
|
+
// the memory behind the string.
|
|
821
|
+
void crossbind_http_string_free(crossbind_http_string_t *ret);
|
|
822
|
+
|
|
823
|
+
#ifdef __cplusplus
|
|
824
|
+
}
|
|
825
|
+
#endif
|
|
826
|
+
#endif
|