Skip to content

Commit 473c901

Browse files
authored
Merge pull request #66 from elliottt/trevor/updates
Fields, timeout, and incoming handler signature changes
2 parents c4e9358 + 1eb8c35 commit 473c901

File tree

2 files changed

+167
-57
lines changed

2 files changed

+167
-57
lines changed

proxy.md

Lines changed: 119 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,11 @@ HTTP Requests and Responses, both incoming and outgoing, as well as
635635
their headers, trailers, and bodies.</p>
636636
<hr />
637637
<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)
640643
<p>
641644
#### <a name="output_stream">`type output-stream`</a>
642645
[`output-stream`](#output_stream)
@@ -678,6 +681,23 @@ initially returning a response.</p>
678681
<li><a name="error.protocol_error"><code>protocol-error</code></a>: <code>string</code></li>
679682
<li><a name="error.unexpected_error"><code>unexpected-error</code></a>: <code>string</code></li>
680683
</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>
681701
<h4><a name="field_key"><code>type field-key</code></a></h4>
682702
<p><code>string</code></p>
683703
<p>Field keys are always strings.
@@ -695,31 +715,7 @@ so they are provided as a list of bytes.
695715
<p>Trailers is an alias for Fields.
696716
<h4><a name="incoming_request"><code>resource incoming-request</code></a></h4>
697717
<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&lt;<code>u32</code>&gt;</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&lt;<code>u32</code>&gt;</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&lt;<code>u32</code>&gt;</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>
723719
<h4><a name="response_outparam"><code>resource response-outparam</code></a></h4>
724720
<h4><a name="status_code"><code>type status-code</code></a></h4>
725721
<p><code>u16</code></p>
@@ -733,6 +729,12 @@ body stream.
733729
<hr />
734730
<h3>Functions</h3>
735731
<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&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>
736+
</ul>
737+
<h4><a name="static_fields.from_list"><code>[static]fields.from-list: func</code></a></h4>
736738
<p>Construct an HTTP Fields.</p>
737739
<p>The list represents each key-value pair in the Fields. Keys
738740
which have multiple values are represented by multiple entries in this
@@ -741,13 +743,15 @@ list with the same key.</p>
741743
Value, represented as a list of bytes. In a valid Fields, all keys
742744
and values are valid UTF-8 strings. However, values are not always
743745
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>
744748
<h5>Params</h5>
745749
<ul>
746-
<li><a name="constructor_fields.entries"><code>entries</code></a>: list&lt;(<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>)&gt;</li>
750+
<li><a name="static_fields.from_list.entries"><code>entries</code></a>: list&lt;(<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>)&gt;</li>
747751
</ul>
748752
<h5>Return values</h5>
749753
<ul>
750-
<li><a name="constructor_fields.0"></a> own&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>
754+
<li><a name="static_fields.from_list.0"></a> result&lt;own&lt;<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>&gt;</li>
751755
</ul>
752756
<h4><a name="method_fields.get"><code>[method]fields.get: func</code></a></h4>
753757
<p>Get all of the values corresponding to a key.</p>
@@ -769,6 +773,10 @@ key, if they have been set.</p>
769773
<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>
770774
<li><a name="method_fields.set.value"><code>value</code></a>: list&lt;<a href="#field_value"><a href="#field_value"><code>field-value</code></a></a>&gt;</li>
771775
</ul>
776+
<h5>Return values</h5>
777+
<ul>
778+
<li><a name="method_fields.set.0"></a> result&lt;_, <a href="#header_error"><a href="#header_error"><code>header-error</code></a></a>&gt;</li>
779+
</ul>
772780
<h4><a name="method_fields.delete"><code>[method]fields.delete: func</code></a></h4>
773781
<p>Delete all values for a key. Does nothing if no values for the key
774782
exist.</p>
@@ -786,6 +794,10 @@ values for that key.</p>
786794
<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>
787795
<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>
788796
</ul>
797+
<h5>Return values</h5>
798+
<ul>
799+
<li><a name="method_fields.append.0"></a> result&lt;_, <a href="#header_error"><a href="#header_error"><code>header-error</code></a></a>&gt;</li>
800+
</ul>
789801
<h4><a name="method_fields.entries"><code>[method]fields.entries: func</code></a></h4>
790802
<p>Retrieve the full set of keys and values in the Fields. Like the
791803
constructor, the list represents each key-value pair.</p>
@@ -1009,6 +1021,80 @@ another component by e.g. <code>outgoing-handler.handle</code>.</p>
10091021
<ul>
10101022
<li><a name="method_outgoing_request.headers.0"></a> own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;</li>
10111023
</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&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;</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&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;</li>
1035+
</ul>
1036+
<h5>Return values</h5>
1037+
<ul>
1038+
<li><a name="method_request_options.connect_timeout_ms.0"></a> option&lt;<a href="#duration"><a href="#duration"><code>duration</code></a></a>&gt;</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&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;</li>
1046+
<li><a name="method_request_options.set_connect_timeout_ms.ms"><code>ms</code></a>: option&lt;<a href="#duration"><a href="#duration"><code>duration</code></a></a>&gt;</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&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;</li>
1057+
</ul>
1058+
<h5>Return values</h5>
1059+
<ul>
1060+
<li><a name="method_request_options.first_byte_timeout_ms.0"></a> option&lt;<a href="#duration"><a href="#duration"><code>duration</code></a></a>&gt;</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&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;</li>
1068+
<li><a name="method_request_options.set_first_byte_timeout_ms.ms"><code>ms</code></a>: option&lt;<a href="#duration"><a href="#duration"><code>duration</code></a></a>&gt;</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&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;</li>
1080+
</ul>
1081+
<h5>Return values</h5>
1082+
<ul>
1083+
<li><a name="method_request_options.between_bytes_timeout_ms.0"></a> option&lt;<a href="#duration"><a href="#duration"><code>duration</code></a></a>&gt;</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&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;</li>
1092+
<li><a name="method_request_options.set_between_bytes_timeout_ms.ms"><code>ms</code></a>: option&lt;<a href="#duration"><a href="#duration"><code>duration</code></a></a>&gt;</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>
10121098
<h4><a name="static_response_outparam.set"><code>[static]response-outparam.set: func</code></a></h4>
10131099
<p>Set the value of the <a href="#response_outparam"><code>response-outparam</code></a> to either send a response,
10141100
or indicate an error.</p>
@@ -1017,18 +1103,11 @@ called at most once. If it is never called, the implementation
10171103
will respond with an error.</p>
10181104
<p>The user may provide an <a href="#error"><code>error</code></a> to <code>response</code> to allow the
10191105
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>
10231106
<h5>Params</h5>
10241107
<ul>
10251108
<li><a name="static_response_outparam.set.param"><code>param</code></a>: own&lt;<a href="#response_outparam"><a href="#response_outparam"><code>response-outparam</code></a></a>&gt;</li>
10261109
<li><a name="static_response_outparam.set.response"><code>response</code></a>: result&lt;own&lt;<a href="#outgoing_response"><a href="#outgoing_response"><code>outgoing-response</code></a></a>&gt;, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
10271110
</ul>
1028-
<h5>Return values</h5>
1029-
<ul>
1030-
<li><a name="static_response_outparam.set.0"></a> result&lt;_, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
1031-
</ul>
10321111
<h4><a name="method_incoming_response.status"><code>[method]incoming-response.status: func</code></a></h4>
10331112
<p>Returns the status code from the incoming response.</p>
10341113
<h5>Params</h5>
@@ -1111,14 +1190,15 @@ once the future is ready.</p>
11111190
<code>option</code> to become <code>some</code> using the <code>subscribe</code> method.</p>
11121191
<p>The <code>result</code> represents that either the HTTP Request or Response body,
11131192
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>
11151195
<h5>Params</h5>
11161196
<ul>
11171197
<li><a name="method_future_trailers.get.self"><code>self</code></a>: borrow&lt;<a href="#future_trailers"><a href="#future_trailers"><code>future-trailers</code></a></a>&gt;</li>
11181198
</ul>
11191199
<h5>Return values</h5>
11201200
<ul>
1121-
<li><a name="method_future_trailers.get.0"></a> option&lt;result&lt;own&lt;<a href="#trailers"><a href="#trailers"><code>trailers</code></a></a>&gt;, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;&gt;</li>
1201+
<li><a name="method_future_trailers.get.0"></a> option&lt;result&lt;option&lt;own&lt;<a href="#trailers"><a href="#trailers"><code>trailers</code></a></a>&gt;&gt;, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;&gt;</li>
11221202
</ul>
11231203
<h4><a name="constructor_outgoing_response"><code>[constructor]outgoing-response: func</code></a></h4>
11241204
<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</
12671347
<h5>Params</h5>
12681348
<ul>
12691349
<li><a name="handle.request"><code>request</code></a>: own&lt;<a href="#outgoing_request"><a href="#outgoing_request"><code>outgoing-request</code></a></a>&gt;</li>
1270-
<li><a name="handle.options"><code>options</code></a>: option&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;</li>
1350+
<li><a name="handle.options"><code>options</code></a>: option&lt;own&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;&gt;</li>
12711351
</ul>
12721352
<h5>Return values</h5>
12731353
<ul>

0 commit comments

Comments
 (0)