@@ -635,8 +635,11 @@ HTTP Requests and Responses, both incoming and outgoing, as well as
635
635
their headers, trailers, and bodies.</p >
636
636
<hr />
637
637
<h3 >Types</h3 >
638
- <h4 ><a name =" input_stream " ><code >type input-stream</code ></a ></h4 >
639
- <p ><a href =" #input_stream " ><a href =" #input_stream " ><code >input-stream</code ></a ></a ></p >
638
+ <h4 ><a name =" duration " ><code >type duration</code ></a ></h4 >
639
+ <p ><a href =" #duration " ><a href =" #duration " ><code >duration</code ></a ></a ></p >
640
+ <p >
641
+ #### <a name =" input_stream " >` type input-stream ` </a >
642
+ [ ` input-stream ` ] ( #input_stream )
640
643
<p >
641
644
#### <a name =" output_stream " >` type output-stream ` </a >
642
645
[ ` output-stream ` ] ( #output_stream )
@@ -678,6 +681,23 @@ initially returning a response.</p>
678
681
<li ><a name =" error.protocol_error " ><code >protocol-error</code ></a >: <code >string</code ></li >
679
682
<li ><a name =" error.unexpected_error " ><code >unexpected-error</code ></a >: <code >string</code ></li >
680
683
</ul >
684
+ <h4 ><a name =" header_error " ><code >variant header-error</code ></a ></h4 >
685
+ <p >This type enumerates the different kinds of errors that may occur when
686
+ setting or appending to a <a href =" #fields " ><code >fields</code ></a > resource.</p >
687
+ <h5 >Variant Cases</h5 >
688
+ <ul >
689
+ <li >
690
+ <p ><a name =" header_error.invalid_syntax " ><code >invalid-syntax</code ></a ></p >
691
+ <p >This error indicates that a `field-key` or `field-value` was
692
+ syntactically invalid when used with an operation that sets headers in a
693
+ ` fields ` .
694
+ </li >
695
+ <li >
696
+ <p ><a name =" header_error.forbidden " ><code >forbidden</code ></a ></p >
697
+ <p >This error indicates that a forbidden `field-key` was used when trying
698
+ to set a header in a ` fields ` .
699
+ </li >
700
+ </ul >
681
701
<h4 ><a name =" field_key " ><code >type field-key</code ></a ></h4 >
682
702
<p ><code >string</code ></p >
683
703
<p >Field keys are always strings.
@@ -695,31 +715,7 @@ so they are provided as a list of bytes.
695
715
<p >Trailers is an alias for Fields.
696
716
<h4 ><a name =" incoming_request " ><code >resource incoming-request</code ></a ></h4 >
697
717
<h4 ><a name =" outgoing_request " ><code >resource outgoing-request</code ></a ></h4 >
698
- <h4 ><a name =" request_options " ><code >record request-options</code ></a ></h4 >
699
- <p >Parameters for making an HTTP Request. Each of these parameters is an
700
- optional timeout, with the unit in milliseconds, applicable to the
701
- transport layer of the HTTP protocol.</p >
702
- <p >These timeouts are separate from any the user may use to bound a
703
- blocking call to <code >wasi: io /poll.poll-list</code >.</p >
704
- <p >FIXME: Make this a resource to allow it to be optionally extended by
705
- future evolution of the standard and/or other interfaces at some later
706
- date?</p >
707
- <h5 >Record Fields</h5 >
708
- <ul >
709
- <li >
710
- <p ><a name =" request_options.connect_timeout_ms " ><code >connect-timeout-ms</code ></a >: option< ; <code >u32</code >> ; </p >
711
- <p >The timeout for the initial connect to the HTTP Server.
712
- </li >
713
- <li >
714
- <p ><a name =" request_options.first_byte_timeout_ms " ><code >first-byte-timeout-ms</code ></a >: option< ; <code >u32</code >> ; </p >
715
- <p >The timeout for receiving the first byte of the Response body.
716
- </li >
717
- <li >
718
- <p ><a name =" request_options.between_bytes_timeout_ms " ><code >between-bytes-timeout-ms</code ></a >: option< ; <code >u32</code >> ; </p >
719
- <p >The timeout for receiving subsequent chunks of bytes in the Response
720
- body stream.
721
- </li >
722
- </ul >
718
+ <h4 ><a name =" request_options " ><code >resource request-options</code ></a ></h4 >
723
719
<h4 ><a name =" response_outparam " ><code >resource response-outparam</code ></a ></h4 >
724
720
<h4 ><a name =" status_code " ><code >type status-code</code ></a ></h4 >
725
721
<p ><code >u16</code ></p >
@@ -733,6 +729,12 @@ body stream.
733
729
<hr />
734
730
<h3 >Functions</h3 >
735
731
<h4 ><a name =" constructor_fields " ><code >[constructor]fields: func</code ></a ></h4 >
732
+ <p >Construct an empty HTTP Fields.</p >
733
+ <h5 >Return values</h5 >
734
+ <ul >
735
+ <li ><a name =" constructor_fields.0 " ></a > own< ; <a href =" #fields " ><a href =" #fields " ><code >fields</code ></a ></a >> ; </li >
736
+ </ul >
737
+ <h4 ><a name =" static_fields.from_list " ><code >[static]fields.from-list: func</code ></a ></h4 >
736
738
<p >Construct an HTTP Fields.</p >
737
739
<p >The list represents each key-value pair in the Fields. Keys
738
740
which have multiple values are represented by multiple entries in this
@@ -741,13 +743,15 @@ list with the same key.</p>
741
743
Value, represented as a list of bytes. In a valid Fields, all keys
742
744
and values are valid UTF-8 strings. However, values are not always
743
745
well-formed, so they are represented as a raw list of bytes.</p >
746
+ <p >An error result will be returned if any header or value was
747
+ syntactically invalid, or if a header was forbidden.</p >
744
748
<h5 >Params</h5 >
745
749
<ul >
746
- <li ><a name =" constructor_fields .entries" ><code >entries</code ></a >: list< ; (<a href =" #field_key " ><a href =" #field_key " ><code >field-key</code ></a ></a >, <a href =" #field_value " ><a href =" #field_value " ><code >field-value</code ></a ></a >)> ; </li >
750
+ <li ><a name =" static_fields.from_list .entries" ><code >entries</code ></a >: list< ; (<a href =" #field_key " ><a href =" #field_key " ><code >field-key</code ></a ></a >, <a href =" #field_value " ><a href =" #field_value " ><code >field-value</code ></a ></a >)> ; </li >
747
751
</ul >
748
752
<h5 >Return values</h5 >
749
753
<ul >
750
- <li ><a name =" constructor_fields. 0" ></a > own< ; <a href =" #fields " ><a href =" #fields " ><code >fields</code ></a ></a >> ; </li >
754
+ <li ><a name =" static_fields.from_list. 0" ></a > result & lt ; own< ; <a href =" #fields " ><a href =" #fields " ><code >fields</ code ></ a ></ a > & gt ; , < a href = " #header_error " >< a href = " #header_error " >< code >header-error </code ></a ></a >> ; </li >
751
755
</ul >
752
756
<h4 ><a name =" method_fields.get " ><code >[method]fields.get: func</code ></a ></h4 >
753
757
<p >Get all of the values corresponding to a key.</p >
@@ -769,6 +773,10 @@ key, if they have been set.</p>
769
773
<li ><a name =" method_fields.set.name " ><code >name</code ></a >: <a href =" #field_key " ><a href =" #field_key " ><code >field-key</code ></a ></a ></li >
770
774
<li ><a name =" method_fields.set.value " ><code >value</code ></a >: list< ; <a href =" #field_value " ><a href =" #field_value " ><code >field-value</code ></a ></a >> ; </li >
771
775
</ul >
776
+ <h5 >Return values</h5 >
777
+ <ul >
778
+ <li ><a name =" method_fields.set.0 " ></a > result< ; _, <a href =" #header_error " ><a href =" #header_error " ><code >header-error</code ></a ></a >> ; </li >
779
+ </ul >
772
780
<h4 ><a name =" method_fields.delete " ><code >[method]fields.delete: func</code ></a ></h4 >
773
781
<p >Delete all values for a key. Does nothing if no values for the key
774
782
exist.</p >
@@ -786,6 +794,10 @@ values for that key.</p>
786
794
<li ><a name =" method_fields.append.name " ><code >name</code ></a >: <a href =" #field_key " ><a href =" #field_key " ><code >field-key</code ></a ></a ></li >
787
795
<li ><a name =" method_fields.append.value " ><code >value</code ></a >: <a href =" #field_value " ><a href =" #field_value " ><code >field-value</code ></a ></a ></li >
788
796
</ul >
797
+ <h5 >Return values</h5 >
798
+ <ul >
799
+ <li ><a name =" method_fields.append.0 " ></a > result< ; _, <a href =" #header_error " ><a href =" #header_error " ><code >header-error</code ></a ></a >> ; </li >
800
+ </ul >
789
801
<h4 ><a name =" method_fields.entries " ><code >[method]fields.entries: func</code ></a ></h4 >
790
802
<p >Retrieve the full set of keys and values in the Fields. Like the
791
803
constructor, the list represents each key-value pair.</p >
@@ -1009,6 +1021,80 @@ another component by e.g. <code>outgoing-handler.handle</code>.</p>
1009
1021
<ul >
1010
1022
<li ><a name =" method_outgoing_request.headers.0 " ></a > own< ; <a href =" #headers " ><a href =" #headers " ><code >headers</code ></a ></a >> ; </li >
1011
1023
</ul >
1024
+ <h4 ><a name =" constructor_request_options " ><code >[constructor]request-options: func</code ></a ></h4 >
1025
+ <p >Construct a default <a href =" #request_options " ><code >request-options</code ></a > value.</p >
1026
+ <h5 >Return values</h5 >
1027
+ <ul >
1028
+ <li ><a name =" constructor_request_options.0 " ></a > own< ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >> ; </li >
1029
+ </ul >
1030
+ <h4 ><a name =" method_request_options.connect_timeout_ms " ><code >[method]request-options.connect-timeout-ms: func</code ></a ></h4 >
1031
+ <p >The timeout for the initial connect to the HTTP Server.</p >
1032
+ <h5 >Params</h5 >
1033
+ <ul >
1034
+ <li ><a name =" method_request_options.connect_timeout_ms.self " ><code >self</code ></a >: borrow< ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >> ; </li >
1035
+ </ul >
1036
+ <h5 >Return values</h5 >
1037
+ <ul >
1038
+ <li ><a name =" method_request_options.connect_timeout_ms.0 " ></a > option< ; <a href =" #duration " ><a href =" #duration " ><code >duration</code ></a ></a >> ; </li >
1039
+ </ul >
1040
+ <h4 ><a name =" method_request_options.set_connect_timeout_ms " ><code >[method]request-options.set-connect-timeout-ms: func</code ></a ></h4 >
1041
+ <p >Set the timeout for the initial connect to the HTTP Server. An error
1042
+ return value indicates that this timeout is not supported.</p >
1043
+ <h5 >Params</h5 >
1044
+ <ul >
1045
+ <li ><a name =" method_request_options.set_connect_timeout_ms.self " ><code >self</code ></a >: borrow< ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >> ; </li >
1046
+ <li ><a name =" method_request_options.set_connect_timeout_ms.ms " ><code >ms</code ></a >: option< ; <a href =" #duration " ><a href =" #duration " ><code >duration</code ></a ></a >> ; </li >
1047
+ </ul >
1048
+ <h5 >Return values</h5 >
1049
+ <ul >
1050
+ <li ><a name =" method_request_options.set_connect_timeout_ms.0 " ></a > result</li >
1051
+ </ul >
1052
+ <h4 ><a name =" method_request_options.first_byte_timeout_ms " ><code >[method]request-options.first-byte-timeout-ms: func</code ></a ></h4 >
1053
+ <p >The timeout for receiving the first byte of the Response body.</p >
1054
+ <h5 >Params</h5 >
1055
+ <ul >
1056
+ <li ><a name =" method_request_options.first_byte_timeout_ms.self " ><code >self</code ></a >: borrow< ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >> ; </li >
1057
+ </ul >
1058
+ <h5 >Return values</h5 >
1059
+ <ul >
1060
+ <li ><a name =" method_request_options.first_byte_timeout_ms.0 " ></a > option< ; <a href =" #duration " ><a href =" #duration " ><code >duration</code ></a ></a >> ; </li >
1061
+ </ul >
1062
+ <h4 ><a name =" method_request_options.set_first_byte_timeout_ms " ><code >[method]request-options.set-first-byte-timeout-ms: func</code ></a ></h4 >
1063
+ <p >Set the timeout for receiving the first byte of the Response body. An
1064
+ error return value indicates that this timeout is not supported.</p >
1065
+ <h5 >Params</h5 >
1066
+ <ul >
1067
+ <li ><a name =" method_request_options.set_first_byte_timeout_ms.self " ><code >self</code ></a >: borrow< ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >> ; </li >
1068
+ <li ><a name =" method_request_options.set_first_byte_timeout_ms.ms " ><code >ms</code ></a >: option< ; <a href =" #duration " ><a href =" #duration " ><code >duration</code ></a ></a >> ; </li >
1069
+ </ul >
1070
+ <h5 >Return values</h5 >
1071
+ <ul >
1072
+ <li ><a name =" method_request_options.set_first_byte_timeout_ms.0 " ></a > result</li >
1073
+ </ul >
1074
+ <h4 ><a name =" method_request_options.between_bytes_timeout_ms " ><code >[method]request-options.between-bytes-timeout-ms: func</code ></a ></h4 >
1075
+ <p >The timeout for receiving subsequent chunks of bytes in the Response
1076
+ body stream.</p >
1077
+ <h5 >Params</h5 >
1078
+ <ul >
1079
+ <li ><a name =" method_request_options.between_bytes_timeout_ms.self " ><code >self</code ></a >: borrow< ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >> ; </li >
1080
+ </ul >
1081
+ <h5 >Return values</h5 >
1082
+ <ul >
1083
+ <li ><a name =" method_request_options.between_bytes_timeout_ms.0 " ></a > option< ; <a href =" #duration " ><a href =" #duration " ><code >duration</code ></a ></a >> ; </li >
1084
+ </ul >
1085
+ <h4 ><a name =" method_request_options.set_between_bytes_timeout_ms " ><code >[method]request-options.set-between-bytes-timeout-ms: func</code ></a ></h4 >
1086
+ <p >Set the timeout for receiving subsequent chunks of bytes in the Response
1087
+ body stream. An error return value indicates that this timeout is not
1088
+ supported.</p >
1089
+ <h5 >Params</h5 >
1090
+ <ul >
1091
+ <li ><a name =" method_request_options.set_between_bytes_timeout_ms.self " ><code >self</code ></a >: borrow< ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >> ; </li >
1092
+ <li ><a name =" method_request_options.set_between_bytes_timeout_ms.ms " ><code >ms</code ></a >: option< ; <a href =" #duration " ><a href =" #duration " ><code >duration</code ></a ></a >> ; </li >
1093
+ </ul >
1094
+ <h5 >Return values</h5 >
1095
+ <ul >
1096
+ <li ><a name =" method_request_options.set_between_bytes_timeout_ms.0 " ></a > result</li >
1097
+ </ul >
1012
1098
<h4 ><a name =" static_response_outparam.set " ><code >[static]response-outparam.set: func</code ></a ></h4 >
1013
1099
<p >Set the value of the <a href =" #response_outparam " ><code >response-outparam</code ></a > to either send a response,
1014
1100
or indicate an error.</p >
@@ -1017,18 +1103,11 @@ called at most once. If it is never called, the implementation
1017
1103
will respond with an error.</p >
1018
1104
<p >The user may provide an <a href =" #error " ><code >error</code ></a > to <code >response</code > to allow the
1019
1105
implementation determine how to respond with an HTTP error response.</p >
1020
- <p >This method may return an error when the <a href =" #outgoing_response " ><code >outgoing-response</code ></a > contains
1021
- a <a href =" #status_code " ><code >status-code</code ></a > or anything else the implementation does not permit or
1022
- support.</p >
1023
1106
<h5 >Params</h5 >
1024
1107
<ul >
1025
1108
<li ><a name =" static_response_outparam.set.param " ><code >param</code ></a >: own< ; <a href =" #response_outparam " ><a href =" #response_outparam " ><code >response-outparam</code ></a ></a >> ; </li >
1026
1109
<li ><a name =" static_response_outparam.set.response " ><code >response</code ></a >: result< ; own< ; <a href =" #outgoing_response " ><a href =" #outgoing_response " ><code >outgoing-response</code ></a ></a >> ; , <a href =" #error " ><a href =" #error " ><code >error</code ></a ></a >> ; </li >
1027
1110
</ul >
1028
- <h5 >Return values</h5 >
1029
- <ul >
1030
- <li ><a name =" static_response_outparam.set.0 " ></a > result< ; _, <a href =" #error " ><a href =" #error " ><code >error</code ></a ></a >> ; </li >
1031
- </ul >
1032
1111
<h4 ><a name =" method_incoming_response.status " ><code >[method]incoming-response.status: func</code ></a ></h4 >
1033
1112
<p >Returns the status code from the incoming response.</p >
1034
1113
<h5 >Params</h5 >
@@ -1111,14 +1190,15 @@ once the future is ready.</p>
1111
1190
<code >option</code > to become <code >some</code > using the <code >subscribe</code > method.</p >
1112
1191
<p >The <code >result</code > represents that either the HTTP Request or Response body,
1113
1192
as well as any trailers, were received successfully, or that an error
1114
- occured receiving them.</p >
1193
+ occured receiving them. The optional <a href =" #trailers " ><code >trailers</code ></a > indicates whether or not
1194
+ trailers were present in the body.</p >
1115
1195
<h5 >Params</h5 >
1116
1196
<ul >
1117
1197
<li ><a name =" method_future_trailers.get.self " ><code >self</code ></a >: borrow< ; <a href =" #future_trailers " ><a href =" #future_trailers " ><code >future-trailers</code ></a ></a >> ; </li >
1118
1198
</ul >
1119
1199
<h5 >Return values</h5 >
1120
1200
<ul >
1121
- <li ><a name =" method_future_trailers.get.0 " ></a > option< ; result< ; own< ; <a href =" #trailers " ><a href =" #trailers " ><code >trailers</code ></a ></a >> ; , <a href =" #error " ><a href =" #error " ><code >error</code ></a ></a >> ;> ; </li >
1201
+ <li ><a name =" method_future_trailers.get.0 " ></a > option< ; result< ; option & lt ; own< ; <a href =" #trailers " ><a href =" #trailers " ><code >trailers</code ></a ></a >& gt ; > ; , <a href =" #error " ><a href =" #error " ><code >error</code ></a ></a >> ;> ; </li >
1122
1202
</ul >
1123
1203
<h4 ><a name =" constructor_outgoing_response " ><code >[constructor]outgoing-response: func</code ></a ></h4 >
1124
1204
<p >Construct an <a href =" #outgoing_response " ><code >outgoing-response</code ></a >.</p >
@@ -1267,7 +1347,7 @@ through the <a href="#future_incoming_response"><code>future-incoming-response</
1267
1347
<h5 >Params</h5 >
1268
1348
<ul >
1269
1349
<li ><a name =" handle.request " ><code >request</code ></a >: own< ; <a href =" #outgoing_request " ><a href =" #outgoing_request " ><code >outgoing-request</code ></a ></a >> ; </li >
1270
- <li ><a name =" handle.options " ><code >options</code ></a >: option< ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >> ; </li >
1350
+ <li ><a name =" handle.options " ><code >options</code ></a >: option< ; own & lt ; <a href =" #request_options " ><a href =" #request_options " ><code >request-options</code ></a ></a >& gt ; > ; </li >
1271
1351
</ul >
1272
1352
<h5 >Return values</h5 >
1273
1353
<ul >
0 commit comments