@bytecodealliance/preview2-shim 0.16.1 → 0.16.2

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.
@@ -13,346 +13,17 @@ export namespace WasiHttpTypes {
13
13
  * http-related errors.
14
14
  */
15
15
  export function httpErrorCode(err: IoError): ErrorCode | undefined;
16
- /**
17
- * Construct an empty HTTP Fields.
18
- *
19
- * The resulting `fields` is mutable.
20
- */
21
16
  export { Fields };
22
- /**
23
- * Construct an HTTP Fields.
24
- *
25
- * The resulting `fields` is mutable.
26
- *
27
- * The list represents each key-value pair in the Fields. Keys
28
- * which have multiple values are represented by multiple entries in this
29
- * list with the same key.
30
- *
31
- * The tuple is a pair of the field key, represented as a string, and
32
- * Value, represented as a list of bytes. In a valid Fields, all keys
33
- * and values are valid UTF-8 strings. However, values are not always
34
- * well-formed, so they are represented as a raw list of bytes.
35
- *
36
- * An error result will be returned if any header or value was
37
- * syntactically invalid, or if a header was forbidden.
38
- */
39
- /**
40
- * Get all of the values corresponding to a key. If the key is not present
41
- * in this `fields`, an empty list is returned. However, if the key is
42
- * present but empty, this is represented by a list with one or more
43
- * empty field-values present.
44
- */
45
- /**
46
- * Returns `true` when the key is present in this `fields`. If the key is
47
- * syntactically invalid, `false` is returned.
48
- */
49
- /**
50
- * Set all of the values for a key. Clears any existing values for that
51
- * key, if they have been set.
52
- *
53
- * Fails with `header-error.immutable` if the `fields` are immutable.
54
- */
55
- /**
56
- * Delete all values for a key. Does nothing if no values for the key
57
- * exist.
58
- *
59
- * Fails with `header-error.immutable` if the `fields` are immutable.
60
- */
61
- /**
62
- * Append a value for a key. Does not change or delete any existing
63
- * values for that key.
64
- *
65
- * Fails with `header-error.immutable` if the `fields` are immutable.
66
- */
67
- /**
68
- * Retrieve the full set of keys and values in the Fields. Like the
69
- * constructor, the list represents each key-value pair.
70
- *
71
- * The outer list represents each key-value pair in the Fields. Keys
72
- * which have multiple values are represented by multiple entries in this
73
- * list with the same key.
74
- */
75
- /**
76
- * Make a deep copy of the Fields. Equivelant in behavior to calling the
77
- * `fields` constructor on the return value of `entries`. The resulting
78
- * `fields` is mutable.
79
- */
80
- /**
81
- * Returns the method of the incoming request.
82
- */
83
17
  export { IncomingRequest };
84
- /**
85
- * Returns the path with query parameters from the request, as a string.
86
- */
87
- /**
88
- * Returns the protocol scheme from the request.
89
- */
90
- /**
91
- * Returns the authority from the request, if it was present.
92
- */
93
- /**
94
- * Get the `headers` associated with the request.
95
- *
96
- * The returned `headers` resource is immutable: `set`, `append`, and
97
- * `delete` operations will fail with `header-error.immutable`.
98
- *
99
- * The `headers` returned are a child resource: it must be dropped before
100
- * the parent `incoming-request` is dropped. Dropping this
101
- * `incoming-request` before all children are dropped will trap.
102
- */
103
- /**
104
- * Gives the `incoming-body` associated with this request. Will only
105
- * return success at most once, and subsequent calls will return error.
106
- */
107
- /**
108
- * Construct a new `outgoing-request` with a default `method` of `GET`, and
109
- * `none` values for `path-with-query`, `scheme`, and `authority`.
110
- *
111
- * * `headers` is the HTTP Headers for the Request.
112
- *
113
- * It is possible to construct, or manipulate with the accessor functions
114
- * below, an `outgoing-request` with an invalid combination of `scheme`
115
- * and `authority`, or `headers` which are not permitted to be sent.
116
- * It is the obligation of the `outgoing-handler.handle` implementation
117
- * to reject invalid constructions of `outgoing-request`.
118
- */
119
18
  export { OutgoingRequest };
120
- /**
121
- * Returns the resource corresponding to the outgoing Body for this
122
- * Request.
123
- *
124
- * Returns success on the first call: the `outgoing-body` resource for
125
- * this `outgoing-request` can be retrieved at most once. Subsequent
126
- * calls will return error.
127
- */
128
- /**
129
- * Get the Method for the Request.
130
- */
131
- /**
132
- * Set the Method for the Request. Fails if the string present in a
133
- * `method.other` argument is not a syntactically valid method.
134
- */
135
- /**
136
- * Get the combination of the HTTP Path and Query for the Request.
137
- * When `none`, this represents an empty Path and empty Query.
138
- */
139
- /**
140
- * Set the combination of the HTTP Path and Query for the Request.
141
- * When `none`, this represents an empty Path and empty Query. Fails is the
142
- * string given is not a syntactically valid path and query uri component.
143
- */
144
- /**
145
- * Get the HTTP Related Scheme for the Request. When `none`, the
146
- * implementation may choose an appropriate default scheme.
147
- */
148
- /**
149
- * Set the HTTP Related Scheme for the Request. When `none`, the
150
- * implementation may choose an appropriate default scheme. Fails if the
151
- * string given is not a syntactically valid uri scheme.
152
- */
153
- /**
154
- * Get the HTTP Authority for the Request. A value of `none` may be used
155
- * with Related Schemes which do not require an Authority. The HTTP and
156
- * HTTPS schemes always require an authority.
157
- */
158
- /**
159
- * Set the HTTP Authority for the Request. A value of `none` may be used
160
- * with Related Schemes which do not require an Authority. The HTTP and
161
- * HTTPS schemes always require an authority. Fails if the string given is
162
- * not a syntactically valid uri authority.
163
- */
164
- /**
165
- * Get the headers associated with the Request.
166
- *
167
- * The returned `headers` resource is immutable: `set`, `append`, and
168
- * `delete` operations will fail with `header-error.immutable`.
169
- *
170
- * This headers resource is a child: it must be dropped before the parent
171
- * `outgoing-request` is dropped, or its ownership is transfered to
172
- * another component by e.g. `outgoing-handler.handle`.
173
- */
174
- /**
175
- * Construct a default `request-options` value.
176
- */
177
19
  export { RequestOptions };
178
- /**
179
- * The timeout for the initial connect to the HTTP Server.
180
- */
181
- /**
182
- * Set the timeout for the initial connect to the HTTP Server. An error
183
- * return value indicates that this timeout is not supported.
184
- */
185
- /**
186
- * The timeout for receiving the first byte of the Response body.
187
- */
188
- /**
189
- * Set the timeout for receiving the first byte of the Response body. An
190
- * error return value indicates that this timeout is not supported.
191
- */
192
- /**
193
- * The timeout for receiving subsequent chunks of bytes in the Response
194
- * body stream.
195
- */
196
- /**
197
- * Set the timeout for receiving subsequent chunks of bytes in the Response
198
- * body stream. An error return value indicates that this timeout is not
199
- * supported.
200
- */
201
- /**
202
- * Set the value of the `response-outparam` to either send a response,
203
- * or indicate an error.
204
- *
205
- * This method consumes the `response-outparam` to ensure that it is
206
- * called at most once. If it is never called, the implementation
207
- * will respond with an error.
208
- *
209
- * The user may provide an `error` to `response` to allow the
210
- * implementation determine how to respond with an HTTP error response.
211
- */
212
20
  export { ResponseOutparam };
213
- /**
214
- * Returns the status code from the incoming response.
215
- */
216
21
  export { IncomingResponse };
217
- /**
218
- * Returns the headers from the incoming response.
219
- *
220
- * The returned `headers` resource is immutable: `set`, `append`, and
221
- * `delete` operations will fail with `header-error.immutable`.
222
- *
223
- * This headers resource is a child: it must be dropped before the parent
224
- * `incoming-response` is dropped.
225
- */
226
- /**
227
- * Returns the incoming body. May be called at most once. Returns error
228
- * if called additional times.
229
- */
230
- /**
231
- * Returns the contents of the body, as a stream of bytes.
232
- *
233
- * Returns success on first call: the stream representing the contents
234
- * can be retrieved at most once. Subsequent calls will return error.
235
- *
236
- * The returned `input-stream` resource is a child: it must be dropped
237
- * before the parent `incoming-body` is dropped, or consumed by
238
- * `incoming-body.finish`.
239
- *
240
- * This invariant ensures that the implementation can determine whether
241
- * the user is consuming the contents of the body, waiting on the
242
- * `future-trailers` to be ready, or neither. This allows for network
243
- * backpressure is to be applied when the user is consuming the body,
244
- * and for that backpressure to not inhibit delivery of the trailers if
245
- * the user does not read the entire body.
246
- */
247
22
  export { IncomingBody };
248
- /**
249
- * Takes ownership of `incoming-body`, and returns a `future-trailers`.
250
- * This function will trap if the `input-stream` child is still alive.
251
- */
252
- /**
253
- * Returns a pollable which becomes ready when either the trailers have
254
- * been received, or an error has occured. When this pollable is ready,
255
- * the `get` method will return `some`.
256
- */
257
23
  export { FutureTrailers };
258
- /**
259
- * Returns the contents of the trailers, or an error which occured,
260
- * once the future is ready.
261
- *
262
- * The outer `option` represents future readiness. Users can wait on this
263
- * `option` to become `some` using the `subscribe` method.
264
- *
265
- * The outer `result` is used to retrieve the trailers or error at most
266
- * once. It will be success on the first call in which the outer option
267
- * is `some`, and error on subsequent calls.
268
- *
269
- * The inner `result` represents that either the HTTP Request or Response
270
- * body, as well as any trailers, were received successfully, or that an
271
- * error occured receiving them. The optional `trailers` indicates whether
272
- * or not trailers were present in the body.
273
- *
274
- * When some `trailers` are returned by this method, the `trailers`
275
- * resource is immutable, and a child. Use of the `set`, `append`, or
276
- * `delete` methods will return an error, and the resource must be
277
- * dropped before the parent `future-trailers` is dropped.
278
- */
279
- /**
280
- * Construct an `outgoing-response`, with a default `status-code` of `200`.
281
- * If a different `status-code` is needed, it must be set via the
282
- * `set-status-code` method.
283
- *
284
- * * `headers` is the HTTP Headers for the Response.
285
- */
286
24
  export { OutgoingResponse };
287
- /**
288
- * Get the HTTP Status Code for the Response.
289
- */
290
- /**
291
- * Set the HTTP Status Code for the Response. Fails if the status-code
292
- * given is not a valid http status code.
293
- */
294
- /**
295
- * Get the headers associated with the Request.
296
- *
297
- * The returned `headers` resource is immutable: `set`, `append`, and
298
- * `delete` operations will fail with `header-error.immutable`.
299
- *
300
- * This headers resource is a child: it must be dropped before the parent
301
- * `outgoing-request` is dropped, or its ownership is transfered to
302
- * another component by e.g. `outgoing-handler.handle`.
303
- */
304
- /**
305
- * Returns the resource corresponding to the outgoing Body for this Response.
306
- *
307
- * Returns success on the first call: the `outgoing-body` resource for
308
- * this `outgoing-response` can be retrieved at most once. Subsequent
309
- * calls will return error.
310
- */
311
- /**
312
- * Returns a stream for writing the body contents.
313
- *
314
- * The returned `output-stream` is a child resource: it must be dropped
315
- * before the parent `outgoing-body` resource is dropped (or finished),
316
- * otherwise the `outgoing-body` drop or `finish` will trap.
317
- *
318
- * Returns success on the first call: the `output-stream` resource for
319
- * this `outgoing-body` may be retrieved at most once. Subsequent calls
320
- * will return error.
321
- */
322
25
  export { OutgoingBody };
323
- /**
324
- * Finalize an outgoing body, optionally providing trailers. This must be
325
- * called to signal that the response is complete. If the `outgoing-body`
326
- * is dropped without calling `outgoing-body.finalize`, the implementation
327
- * should treat the body as corrupted.
328
- *
329
- * Fails if the body's `outgoing-request` or `outgoing-response` was
330
- * constructed with a Content-Length header, and the contents written
331
- * to the body (via `write`) does not match the value given in the
332
- * Content-Length.
333
- */
334
- /**
335
- * Returns a pollable which becomes ready when either the Response has
336
- * been received, or an error has occured. When this pollable is ready,
337
- * the `get` method will return `some`.
338
- */
339
26
  export { FutureIncomingResponse };
340
- /**
341
- * Returns the incoming HTTP Response, or an error, once one is ready.
342
- *
343
- * The outer `option` represents future readiness. Users can wait on this
344
- * `option` to become `some` using the `subscribe` method.
345
- *
346
- * The outer `result` is used to retrieve the response or error at most
347
- * once. It will be success on the first call in which the outer option
348
- * is `some`, and error on subsequent calls.
349
- *
350
- * The inner `result` represents that either the incoming HTTP Response
351
- * status and headers have recieved successfully, or that an error
352
- * occured. Errors may also occur while consuming the response body,
353
- * but those will be reported by the `incoming-body` and its
354
- * `output-stream` child.
355
- */
356
27
  }
357
28
  import type { Duration } from './wasi-clocks-monotonic-clock.js';
358
29
  export { Duration };
@@ -629,85 +300,414 @@ export type Trailers = Fields;
629
300
  export type StatusCode = number;
630
301
  export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
631
302
 
632
- export class OutgoingResponse {
633
- constructor(headers: Headers)
634
- statusCode(): StatusCode;
635
- setStatusCode(statusCode: StatusCode): void;
636
- headers(): Headers;
637
- body(): OutgoingBody;
303
+ export class Fields {
304
+ /**
305
+ * Construct an empty HTTP Fields.
306
+ *
307
+ * The resulting `fields` is mutable.
308
+ */
309
+ constructor()
310
+ /**
311
+ * Construct an HTTP Fields.
312
+ *
313
+ * The resulting `fields` is mutable.
314
+ *
315
+ * The list represents each key-value pair in the Fields. Keys
316
+ * which have multiple values are represented by multiple entries in this
317
+ * list with the same key.
318
+ *
319
+ * The tuple is a pair of the field key, represented as a string, and
320
+ * Value, represented as a list of bytes. In a valid Fields, all keys
321
+ * and values are valid UTF-8 strings. However, values are not always
322
+ * well-formed, so they are represented as a raw list of bytes.
323
+ *
324
+ * An error result will be returned if any header or value was
325
+ * syntactically invalid, or if a header was forbidden.
326
+ */
327
+ static fromList(entries: [FieldKey, FieldValue][]): Fields;
328
+ /**
329
+ * Get all of the values corresponding to a key. If the key is not present
330
+ * in this `fields`, an empty list is returned. However, if the key is
331
+ * present but empty, this is represented by a list with one or more
332
+ * empty field-values present.
333
+ */
334
+ get(name: FieldKey): FieldValue[];
335
+ /**
336
+ * Returns `true` when the key is present in this `fields`. If the key is
337
+ * syntactically invalid, `false` is returned.
338
+ */
339
+ has(name: FieldKey): boolean;
340
+ /**
341
+ * Set all of the values for a key. Clears any existing values for that
342
+ * key, if they have been set.
343
+ *
344
+ * Fails with `header-error.immutable` if the `fields` are immutable.
345
+ */
346
+ set(name: FieldKey, value: FieldValue[]): void;
347
+ /**
348
+ * Delete all values for a key. Does nothing if no values for the key
349
+ * exist.
350
+ *
351
+ * Fails with `header-error.immutable` if the `fields` are immutable.
352
+ */
353
+ 'delete'(name: FieldKey): void;
354
+ /**
355
+ * Append a value for a key. Does not change or delete any existing
356
+ * values for that key.
357
+ *
358
+ * Fails with `header-error.immutable` if the `fields` are immutable.
359
+ */
360
+ append(name: FieldKey, value: FieldValue): void;
361
+ /**
362
+ * Retrieve the full set of keys and values in the Fields. Like the
363
+ * constructor, the list represents each key-value pair.
364
+ *
365
+ * The outer list represents each key-value pair in the Fields. Keys
366
+ * which have multiple values are represented by multiple entries in this
367
+ * list with the same key.
368
+ */
369
+ entries(): [FieldKey, FieldValue][];
370
+ /**
371
+ * Make a deep copy of the Fields. Equivelant in behavior to calling the
372
+ * `fields` constructor on the return value of `entries`. The resulting
373
+ * `fields` is mutable.
374
+ */
375
+ clone(): Fields;
638
376
  }
639
377
 
640
- export class OutgoingBody {
641
- write(): OutputStream;
642
- static finish(this_: OutgoingBody, trailers: Trailers | undefined): void;
378
+ export class FutureIncomingResponse {
379
+ /**
380
+ * Returns a pollable which becomes ready when either the Response has
381
+ * been received, or an error has occured. When this pollable is ready,
382
+ * the `get` method will return `some`.
383
+ */
384
+ subscribe(): Pollable;
385
+ /**
386
+ * Returns the incoming HTTP Response, or an error, once one is ready.
387
+ *
388
+ * The outer `option` represents future readiness. Users can wait on this
389
+ * `option` to become `some` using the `subscribe` method.
390
+ *
391
+ * The outer `result` is used to retrieve the response or error at most
392
+ * once. It will be success on the first call in which the outer option
393
+ * is `some`, and error on subsequent calls.
394
+ *
395
+ * The inner `result` represents that either the incoming HTTP Response
396
+ * status and headers have recieved successfully, or that an error
397
+ * occured. Errors may also occur while consuming the response body,
398
+ * but those will be reported by the `incoming-body` and its
399
+ * `output-stream` child.
400
+ */
401
+ get(): Result<Result<IncomingResponse, ErrorCode>, void> | undefined;
402
+ }
403
+
404
+ export class FutureTrailers {
405
+ /**
406
+ * Returns a pollable which becomes ready when either the trailers have
407
+ * been received, or an error has occured. When this pollable is ready,
408
+ * the `get` method will return `some`.
409
+ */
410
+ subscribe(): Pollable;
411
+ /**
412
+ * Returns the contents of the trailers, or an error which occured,
413
+ * once the future is ready.
414
+ *
415
+ * The outer `option` represents future readiness. Users can wait on this
416
+ * `option` to become `some` using the `subscribe` method.
417
+ *
418
+ * The outer `result` is used to retrieve the trailers or error at most
419
+ * once. It will be success on the first call in which the outer option
420
+ * is `some`, and error on subsequent calls.
421
+ *
422
+ * The inner `result` represents that either the HTTP Request or Response
423
+ * body, as well as any trailers, were received successfully, or that an
424
+ * error occured receiving them. The optional `trailers` indicates whether
425
+ * or not trailers were present in the body.
426
+ *
427
+ * When some `trailers` are returned by this method, the `trailers`
428
+ * resource is immutable, and a child. Use of the `set`, `append`, or
429
+ * `delete` methods will return an error, and the resource must be
430
+ * dropped before the parent `future-trailers` is dropped.
431
+ */
432
+ get(): Result<Result<Trailers | undefined, ErrorCode>, void> | undefined;
433
+ }
434
+
435
+ export class IncomingBody {
436
+ /**
437
+ * Returns the contents of the body, as a stream of bytes.
438
+ *
439
+ * Returns success on first call: the stream representing the contents
440
+ * can be retrieved at most once. Subsequent calls will return error.
441
+ *
442
+ * The returned `input-stream` resource is a child: it must be dropped
443
+ * before the parent `incoming-body` is dropped, or consumed by
444
+ * `incoming-body.finish`.
445
+ *
446
+ * This invariant ensures that the implementation can determine whether
447
+ * the user is consuming the contents of the body, waiting on the
448
+ * `future-trailers` to be ready, or neither. This allows for network
449
+ * backpressure is to be applied when the user is consuming the body,
450
+ * and for that backpressure to not inhibit delivery of the trailers if
451
+ * the user does not read the entire body.
452
+ */
453
+ stream(): InputStream;
454
+ /**
455
+ * Takes ownership of `incoming-body`, and returns a `future-trailers`.
456
+ * This function will trap if the `input-stream` child is still alive.
457
+ */
458
+ static finish(this_: IncomingBody): FutureTrailers;
459
+ }
460
+
461
+ export class IncomingRequest {
462
+ /**
463
+ * Returns the method of the incoming request.
464
+ */
465
+ method(): Method;
466
+ /**
467
+ * Returns the path with query parameters from the request, as a string.
468
+ */
469
+ pathWithQuery(): string | undefined;
470
+ /**
471
+ * Returns the protocol scheme from the request.
472
+ */
473
+ scheme(): Scheme | undefined;
474
+ /**
475
+ * Returns the authority from the request, if it was present.
476
+ */
477
+ authority(): string | undefined;
478
+ /**
479
+ * Get the `headers` associated with the request.
480
+ *
481
+ * The returned `headers` resource is immutable: `set`, `append`, and
482
+ * `delete` operations will fail with `header-error.immutable`.
483
+ *
484
+ * The `headers` returned are a child resource: it must be dropped before
485
+ * the parent `incoming-request` is dropped. Dropping this
486
+ * `incoming-request` before all children are dropped will trap.
487
+ */
488
+ headers(): Headers;
489
+ /**
490
+ * Gives the `incoming-body` associated with this request. Will only
491
+ * return success at most once, and subsequent calls will return error.
492
+ */
493
+ consume(): IncomingBody;
643
494
  }
644
495
 
645
496
  export class IncomingResponse {
497
+ /**
498
+ * Returns the status code from the incoming response.
499
+ */
646
500
  status(): StatusCode;
501
+ /**
502
+ * Returns the headers from the incoming response.
503
+ *
504
+ * The returned `headers` resource is immutable: `set`, `append`, and
505
+ * `delete` operations will fail with `header-error.immutable`.
506
+ *
507
+ * This headers resource is a child: it must be dropped before the parent
508
+ * `incoming-response` is dropped.
509
+ */
647
510
  headers(): Headers;
511
+ /**
512
+ * Returns the incoming body. May be called at most once. Returns error
513
+ * if called additional times.
514
+ */
648
515
  consume(): IncomingBody;
649
516
  }
650
517
 
651
- export class RequestOptions {
652
- constructor()
653
- connectTimeout(): Duration | undefined;
654
- setConnectTimeout(duration: Duration | undefined): void;
655
- firstByteTimeout(): Duration | undefined;
656
- setFirstByteTimeout(duration: Duration | undefined): void;
657
- betweenBytesTimeout(): Duration | undefined;
658
- setBetweenBytesTimeout(duration: Duration | undefined): void;
518
+ export class OutgoingBody {
519
+ /**
520
+ * Returns a stream for writing the body contents.
521
+ *
522
+ * The returned `output-stream` is a child resource: it must be dropped
523
+ * before the parent `outgoing-body` resource is dropped (or finished),
524
+ * otherwise the `outgoing-body` drop or `finish` will trap.
525
+ *
526
+ * Returns success on the first call: the `output-stream` resource for
527
+ * this `outgoing-body` may be retrieved at most once. Subsequent calls
528
+ * will return error.
529
+ */
530
+ write(): OutputStream;
531
+ /**
532
+ * Finalize an outgoing body, optionally providing trailers. This must be
533
+ * called to signal that the response is complete. If the `outgoing-body`
534
+ * is dropped without calling `outgoing-body.finalize`, the implementation
535
+ * should treat the body as corrupted.
536
+ *
537
+ * Fails if the body's `outgoing-request` or `outgoing-response` was
538
+ * constructed with a Content-Length header, and the contents written
539
+ * to the body (via `write`) does not match the value given in the
540
+ * Content-Length.
541
+ */
542
+ static finish(this_: OutgoingBody, trailers: Trailers | undefined): void;
659
543
  }
660
544
 
661
545
  export class OutgoingRequest {
546
+ /**
547
+ * Construct a new `outgoing-request` with a default `method` of `GET`, and
548
+ * `none` values for `path-with-query`, `scheme`, and `authority`.
549
+ *
550
+ * * `headers` is the HTTP Headers for the Request.
551
+ *
552
+ * It is possible to construct, or manipulate with the accessor functions
553
+ * below, an `outgoing-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 `outgoing-handler.handle` implementation
556
+ * to reject invalid constructions of `outgoing-request`.
557
+ */
662
558
  constructor(headers: Headers)
559
+ /**
560
+ * Returns the resource corresponding to the outgoing Body for this
561
+ * Request.
562
+ *
563
+ * Returns success on the first call: the `outgoing-body` resource for
564
+ * this `outgoing-request` can be retrieved at most once. Subsequent
565
+ * calls will return error.
566
+ */
663
567
  body(): OutgoingBody;
568
+ /**
569
+ * Get the Method for the Request.
570
+ */
664
571
  method(): Method;
572
+ /**
573
+ * Set the Method for the Request. Fails if the string present in a
574
+ * `method.other` argument is not a syntactically valid method.
575
+ */
665
576
  setMethod(method: Method): void;
577
+ /**
578
+ * Get the combination of the HTTP Path and Query for the Request.
579
+ * When `none`, this represents an empty Path and empty Query.
580
+ */
666
581
  pathWithQuery(): string | undefined;
582
+ /**
583
+ * Set the combination of the HTTP Path and Query for the Request.
584
+ * When `none`, this represents an empty Path and empty Query. Fails is the
585
+ * string given is not a syntactically valid path and query uri component.
586
+ */
667
587
  setPathWithQuery(pathWithQuery: string | undefined): void;
588
+ /**
589
+ * Get the HTTP Related Scheme for the Request. When `none`, the
590
+ * implementation may choose an appropriate default scheme.
591
+ */
668
592
  scheme(): Scheme | undefined;
593
+ /**
594
+ * Set the HTTP Related Scheme for the Request. When `none`, the
595
+ * implementation may choose an appropriate default scheme. Fails if the
596
+ * string given is not a syntactically valid uri scheme.
597
+ */
669
598
  setScheme(scheme: Scheme | undefined): void;
599
+ /**
600
+ * Get the HTTP Authority for the Request. A value of `none` may be used
601
+ * with Related Schemes which do not require an Authority. The HTTP and
602
+ * HTTPS schemes always require an authority.
603
+ */
670
604
  authority(): string | undefined;
605
+ /**
606
+ * Set the HTTP Authority for the Request. A value of `none` may be used
607
+ * with Related Schemes which do not require an Authority. The HTTP and
608
+ * HTTPS schemes always require an authority. Fails if the string given is
609
+ * not a syntactically valid uri authority.
610
+ */
671
611
  setAuthority(authority: string | undefined): void;
612
+ /**
613
+ * Get the headers associated with the Request.
614
+ *
615
+ * The returned `headers` resource is immutable: `set`, `append`, and
616
+ * `delete` operations will fail with `header-error.immutable`.
617
+ *
618
+ * This headers resource is a child: it must be dropped before the parent
619
+ * `outgoing-request` is dropped, or its ownership is transfered to
620
+ * another component by e.g. `outgoing-handler.handle`.
621
+ */
672
622
  headers(): Headers;
673
623
  }
674
624
 
675
- export class IncomingRequest {
676
- method(): Method;
677
- pathWithQuery(): string | undefined;
678
- scheme(): Scheme | undefined;
679
- authority(): string | undefined;
625
+ export class OutgoingResponse {
626
+ /**
627
+ * Construct an `outgoing-response`, with a default `status-code` of `200`.
628
+ * If a different `status-code` is needed, it must be set via the
629
+ * `set-status-code` method.
630
+ *
631
+ * * `headers` is the HTTP Headers for the Response.
632
+ */
633
+ constructor(headers: Headers)
634
+ /**
635
+ * Get the HTTP Status Code for the Response.
636
+ */
637
+ statusCode(): StatusCode;
638
+ /**
639
+ * Set the HTTP Status Code for the Response. Fails if the status-code
640
+ * given is not a valid http status code.
641
+ */
642
+ setStatusCode(statusCode: StatusCode): void;
643
+ /**
644
+ * Get the headers associated with the Request.
645
+ *
646
+ * The returned `headers` resource is immutable: `set`, `append`, and
647
+ * `delete` operations will fail with `header-error.immutable`.
648
+ *
649
+ * This headers resource is a child: it must be dropped before the parent
650
+ * `outgoing-request` is dropped, or its ownership is transfered to
651
+ * another component by e.g. `outgoing-handler.handle`.
652
+ */
680
653
  headers(): Headers;
681
- consume(): IncomingBody;
654
+ /**
655
+ * Returns the resource corresponding to the outgoing Body for this Response.
656
+ *
657
+ * Returns success on the first call: the `outgoing-body` resource for
658
+ * this `outgoing-response` can be retrieved at most once. Subsequent
659
+ * calls will return error.
660
+ */
661
+ body(): OutgoingBody;
682
662
  }
683
663
 
684
- export class Fields {
664
+ export class RequestOptions {
665
+ /**
666
+ * Construct a default `request-options` value.
667
+ */
685
668
  constructor()
686
- static fromList(entries: [FieldKey, FieldValue][]): Fields;
687
- get(name: FieldKey): FieldValue[];
688
- has(name: FieldKey): boolean;
689
- set(name: FieldKey, value: FieldValue[]): void;
690
- 'delete'(name: FieldKey): void;
691
- append(name: FieldKey, value: FieldValue): void;
692
- entries(): [FieldKey, FieldValue][];
693
- clone(): Fields;
694
- }
695
-
696
- export class FutureTrailers {
697
- subscribe(): Pollable;
698
- get(): Result<Result<Trailers | undefined, ErrorCode>, void> | undefined;
699
- }
700
-
701
- export class FutureIncomingResponse {
702
- subscribe(): Pollable;
703
- get(): Result<Result<IncomingResponse, ErrorCode>, void> | undefined;
704
- }
705
-
706
- export class IncomingBody {
707
- stream(): InputStream;
708
- static finish(this_: IncomingBody): FutureTrailers;
669
+ /**
670
+ * The timeout for the initial connect to the HTTP Server.
671
+ */
672
+ connectTimeout(): Duration | undefined;
673
+ /**
674
+ * Set the timeout for the initial connect to the HTTP Server. An error
675
+ * return value indicates that this timeout is not supported.
676
+ */
677
+ setConnectTimeout(duration: Duration | undefined): void;
678
+ /**
679
+ * The timeout for receiving the first byte of the Response body.
680
+ */
681
+ firstByteTimeout(): Duration | undefined;
682
+ /**
683
+ * Set the timeout for receiving the first byte of the Response body. An
684
+ * error return value indicates that this timeout is not supported.
685
+ */
686
+ setFirstByteTimeout(duration: Duration | undefined): void;
687
+ /**
688
+ * The timeout for receiving subsequent chunks of bytes in the Response
689
+ * body stream.
690
+ */
691
+ betweenBytesTimeout(): Duration | undefined;
692
+ /**
693
+ * Set the timeout for receiving subsequent chunks of bytes in the Response
694
+ * body stream. An error return value indicates that this timeout is not
695
+ * supported.
696
+ */
697
+ setBetweenBytesTimeout(duration: Duration | undefined): void;
709
698
  }
710
699
 
711
700
  export class ResponseOutparam {
701
+ /**
702
+ * Set the value of the `response-outparam` to either send a response,
703
+ * or indicate an error.
704
+ *
705
+ * This method consumes the `response-outparam` to ensure that it is
706
+ * called at most once. If it is never called, the implementation
707
+ * will respond with an error.
708
+ *
709
+ * The user may provide an `error` to `response` to allow the
710
+ * implementation determine how to respond with an HTTP error response.
711
+ */
712
712
  static set(param: ResponseOutparam, response: Result<OutgoingResponse, ErrorCode>): void;
713
713
  }