Skip to content

Commit 8c70f87

Browse files
authored
Fallible setters, and fields.delete method (#69)
* Make the `fields.delete` method fallible * Make setters fallible * Regenerate proxy.md
1 parent 473c901 commit 8c70f87

File tree

2 files changed

+64
-53
lines changed

2 files changed

+64
-53
lines changed

proxy.md

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,10 @@ exist.</p>
785785
<li><a name="method_fields.delete.self"><code>self</code></a>: borrow&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>
786786
<li><a name="method_fields.delete.name"><code>name</code></a>: <a href="#field_key"><a href="#field_key"><code>field-key</code></a></a></li>
787787
</ul>
788+
<h5>Return values</h5>
789+
<ul>
790+
<li><a name="method_fields.delete.0"></a> result&lt;_, <a href="#header_error"><a href="#header_error"><code>header-error</code></a></a>&gt;</li>
791+
</ul>
788792
<h4><a name="method_fields.append"><code>[method]fields.append: func</code></a></h4>
789793
<p>Append a value for a key. Does not change or delete any existing
790794
values for that key.</p>
@@ -888,17 +892,9 @@ return success at most once, and subsequent calls will return error.</p>
888892
<li><a name="method_incoming_request.consume.0"></a> result&lt;own&lt;<a href="#incoming_body"><a href="#incoming_body"><code>incoming-body</code></a></a>&gt;&gt;</li>
889893
</ul>
890894
<h4><a name="constructor_outgoing_request"><code>[constructor]outgoing-request: func</code></a></h4>
891-
<p>Construct a new <a href="#outgoing_request"><code>outgoing-request</code></a>.</p>
892-
<ul>
893-
<li><a href="#method"><code>method</code></a> represents the HTTP Method for the Request.</li>
894-
<li><code>path-with-query</code> is the combination of the HTTP Path and Query for
895-
the Request. When <code>none</code>, this represents an empty Path and empty
896-
Query.</li>
897-
<li><a href="#scheme"><code>scheme</code></a> is the HTTP Related Scheme for the Request. When <code>none</code>,
898-
the implementation may choose an appropriate default scheme.</li>
899-
<li><code>authority</code> is the HTTP Authority for the Request. A value of <code>none</code>
900-
may be used with Related Schemes which do not require an Authority.
901-
The HTTP and HTTPS schemes always require an authority.</li>
895+
<p>Construct a new <a href="#outgoing_request"><code>outgoing-request</code></a> with a default <a href="#method"><code>method</code></a> of <code>GET</code>, and
896+
<code>none</code> values for <code>path-with-query</code>, <a href="#scheme"><code>scheme</code></a>, and <code>authority</code>.</p>
897+
<ul>
902898
<li><a href="#headers"><code>headers</code></a> is the HTTP Headers for the Request.</li>
903899
</ul>
904900
<p>It is possible to construct, or manipulate with the accessor functions
@@ -908,10 +904,6 @@ It is the obligation of the <code>outgoing-handler.handle</code> implementation
908904
to reject invalid constructions of <a href="#outgoing_request"><code>outgoing-request</code></a>.</p>
909905
<h5>Params</h5>
910906
<ul>
911-
<li><a name="constructor_outgoing_request.method"><a href="#method"><code>method</code></a></a>: <a href="#method"><a href="#method"><code>method</code></a></a></li>
912-
<li><a name="constructor_outgoing_request.path_with_query"><code>path-with-query</code></a>: option&lt;<code>string</code>&gt;</li>
913-
<li><a name="constructor_outgoing_request.scheme"><a href="#scheme"><code>scheme</code></a></a>: option&lt;<a href="#scheme"><a href="#scheme"><code>scheme</code></a></a>&gt;</li>
914-
<li><a name="constructor_outgoing_request.authority"><code>authority</code></a>: option&lt;<code>string</code>&gt;</li>
915907
<li><a name="constructor_outgoing_request.headers"><a href="#headers"><code>headers</code></a></a>: own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;</li>
916908
</ul>
917909
<h5>Return values</h5>
@@ -943,12 +935,17 @@ calls will return error.</p>
943935
<li><a name="method_outgoing_request.method.0"></a> <a href="#method"><a href="#method"><code>method</code></a></a></li>
944936
</ul>
945937
<h4><a name="method_outgoing_request.set_method"><code>[method]outgoing-request.set-method: func</code></a></h4>
946-
<p>Set the Method for the Request.</p>
938+
<p>Set the Method for the Request. Fails if the string present in a
939+
<code>method.other</code> argument is not a syntactically valid method.</p>
947940
<h5>Params</h5>
948941
<ul>
949942
<li><a name="method_outgoing_request.set_method.self"><code>self</code></a>: borrow&lt;<a href="#outgoing_request"><a href="#outgoing_request"><code>outgoing-request</code></a></a>&gt;</li>
950943
<li><a name="method_outgoing_request.set_method.method"><a href="#method"><code>method</code></a></a>: <a href="#method"><a href="#method"><code>method</code></a></a></li>
951944
</ul>
945+
<h5>Return values</h5>
946+
<ul>
947+
<li><a name="method_outgoing_request.set_method.0"></a> result</li>
948+
</ul>
952949
<h4><a name="method_outgoing_request.path_with_query"><code>[method]outgoing-request.path-with-query: func</code></a></h4>
953950
<p>Get the combination of the HTTP Path and Query for the Request.
954951
When <code>none</code>, this represents an empty Path and empty Query.</p>
@@ -962,12 +959,17 @@ When <code>none</code>, this represents an empty Path and empty Query.</p>
962959
</ul>
963960
<h4><a name="method_outgoing_request.set_path_with_query"><code>[method]outgoing-request.set-path-with-query: func</code></a></h4>
964961
<p>Set the combination of the HTTP Path and Query for the Request.
965-
When <code>none</code>, this represents an empty Path and empty Query.</p>
962+
When <code>none</code>, this represents an empty Path and empty Query. Fails is the
963+
string given is not a syntactically valid path and query uri component.</p>
966964
<h5>Params</h5>
967965
<ul>
968966
<li><a name="method_outgoing_request.set_path_with_query.self"><code>self</code></a>: borrow&lt;<a href="#outgoing_request"><a href="#outgoing_request"><code>outgoing-request</code></a></a>&gt;</li>
969967
<li><a name="method_outgoing_request.set_path_with_query.path_with_query"><code>path-with-query</code></a>: option&lt;<code>string</code>&gt;</li>
970968
</ul>
969+
<h5>Return values</h5>
970+
<ul>
971+
<li><a name="method_outgoing_request.set_path_with_query.0"></a> result</li>
972+
</ul>
971973
<h4><a name="method_outgoing_request.scheme"><code>[method]outgoing-request.scheme: func</code></a></h4>
972974
<p>Get the HTTP Related Scheme for the Request. When <code>none</code>, the
973975
implementation may choose an appropriate default scheme.</p>
@@ -981,12 +983,17 @@ implementation may choose an appropriate default scheme.</p>
981983
</ul>
982984
<h4><a name="method_outgoing_request.set_scheme"><code>[method]outgoing-request.set-scheme: func</code></a></h4>
983985
<p>Set the HTTP Related Scheme for the Request. When <code>none</code>, the
984-
implementation may choose an appropriate default scheme.</p>
986+
implementation may choose an appropriate default scheme. Fails if the
987+
string given is not a syntactically valid uri scheme.</p>
985988
<h5>Params</h5>
986989
<ul>
987990
<li><a name="method_outgoing_request.set_scheme.self"><code>self</code></a>: borrow&lt;<a href="#outgoing_request"><a href="#outgoing_request"><code>outgoing-request</code></a></a>&gt;</li>
988991
<li><a name="method_outgoing_request.set_scheme.scheme"><a href="#scheme"><code>scheme</code></a></a>: option&lt;<a href="#scheme"><a href="#scheme"><code>scheme</code></a></a>&gt;</li>
989992
</ul>
993+
<h5>Return values</h5>
994+
<ul>
995+
<li><a name="method_outgoing_request.set_scheme.0"></a> result</li>
996+
</ul>
990997
<h4><a name="method_outgoing_request.authority"><code>[method]outgoing-request.authority: func</code></a></h4>
991998
<p>Get the HTTP Authority for the Request. A value of <code>none</code> may be used
992999
with Related Schemes which do not require an Authority. The HTTP and
@@ -1002,12 +1009,17 @@ HTTPS schemes always require an authority.</p>
10021009
<h4><a name="method_outgoing_request.set_authority"><code>[method]outgoing-request.set-authority: func</code></a></h4>
10031010
<p>Set the HTTP Authority for the Request. A value of <code>none</code> may be used
10041011
with Related Schemes which do not require an Authority. The HTTP and
1005-
HTTPS schemes always require an authority.</p>
1012+
HTTPS schemes always require an authority. Fails if the string given is
1013+
not a syntactically valid uri authority.</p>
10061014
<h5>Params</h5>
10071015
<ul>
10081016
<li><a name="method_outgoing_request.set_authority.self"><code>self</code></a>: borrow&lt;<a href="#outgoing_request"><a href="#outgoing_request"><code>outgoing-request</code></a></a>&gt;</li>
10091017
<li><a name="method_outgoing_request.set_authority.authority"><code>authority</code></a>: option&lt;<code>string</code>&gt;</li>
10101018
</ul>
1019+
<h5>Return values</h5>
1020+
<ul>
1021+
<li><a name="method_outgoing_request.set_authority.0"></a> result</li>
1022+
</ul>
10111023
<h4><a name="method_outgoing_request.headers"><code>[method]outgoing-request.headers: func</code></a></h4>
10121024
<p>Get the headers associated with the Request.</p>
10131025
<p>This headers resource is a child: it must be dropped before the parent
@@ -1201,14 +1213,14 @@ trailers were present in the body.</p>
12011213
<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>
12021214
</ul>
12031215
<h4><a name="constructor_outgoing_response"><code>[constructor]outgoing-response: func</code></a></h4>
1204-
<p>Construct an <a href="#outgoing_response"><code>outgoing-response</code></a>.</p>
1216+
<p>Construct an <a href="#outgoing_response"><code>outgoing-response</code></a>, with a default <a href="#status_code"><code>status-code</code></a> of <code>200</code>.
1217+
If a different <a href="#status_code"><code>status-code</code></a> is needed, it must be set via the
1218+
<code>set-status-code</code> method.</p>
12051219
<ul>
1206-
<li><a href="#status_code"><code>status-code</code></a> is the HTTP Status Code for the Response.</li>
12071220
<li><a href="#headers"><code>headers</code></a> is the HTTP Headers for the Response.</li>
12081221
</ul>
12091222
<h5>Params</h5>
12101223
<ul>
1211-
<li><a name="constructor_outgoing_response.status_code"><a href="#status_code"><code>status-code</code></a></a>: <a href="#status_code"><a href="#status_code"><code>status-code</code></a></a></li>
12121224
<li><a name="constructor_outgoing_response.headers"><a href="#headers"><code>headers</code></a></a>: own&lt;<a href="#headers"><a href="#headers"><code>headers</code></a></a>&gt;</li>
12131225
</ul>
12141226
<h5>Return values</h5>
@@ -1226,12 +1238,17 @@ trailers were present in the body.</p>
12261238
<li><a name="method_outgoing_response.status_code.0"></a> <a href="#status_code"><a href="#status_code"><code>status-code</code></a></a></li>
12271239
</ul>
12281240
<h4><a name="method_outgoing_response.set_status_code"><code>[method]outgoing-response.set-status-code: func</code></a></h4>
1229-
<p>Set the HTTP Status Code for the Response.</p>
1241+
<p>Set the HTTP Status Code for the Response. Fails if the status-code
1242+
given is not a valid http status code.</p>
12301243
<h5>Params</h5>
12311244
<ul>
12321245
<li><a name="method_outgoing_response.set_status_code.self"><code>self</code></a>: borrow&lt;<a href="#outgoing_response"><a href="#outgoing_response"><code>outgoing-response</code></a></a>&gt;</li>
12331246
<li><a name="method_outgoing_response.set_status_code.status_code"><a href="#status_code"><code>status-code</code></a></a>: <a href="#status_code"><a href="#status_code"><code>status-code</code></a></a></li>
12341247
</ul>
1248+
<h5>Return values</h5>
1249+
<ul>
1250+
<li><a name="method_outgoing_response.set_status_code.0"></a> result</li>
1251+
</ul>
12351252
<h4><a name="method_outgoing_response.headers"><code>[method]outgoing-response.headers: func</code></a></h4>
12361253
<p>Get the headers associated with the Request.</p>
12371254
<p>This headers resource is a child: it must be dropped before the parent

wit/types.wit

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,12 @@ interface types {
9292

9393
/// Delete all values for a key. Does nothing if no values for the key
9494
/// exist.
95-
delete: func(name: field-key);
95+
delete: func(name: field-key) -> result<_, header-error>;
9696

9797
/// Append a value for a key. Does not change or delete any existing
9898
/// values for that key.
9999
append: func(name: field-key, value: field-value) -> result<_, header-error>;
100100

101-
102101
/// Retrieve the full set of keys and values in the Fields. Like the
103102
/// constructor, the list represents each key-value pair.
104103
///
@@ -148,17 +147,9 @@ interface types {
148147
/// Represents an outgoing HTTP Request.
149148
resource outgoing-request {
150149

151-
/// Construct a new `outgoing-request`.
150+
/// Construct a new `outgoing-request` with a default `method` of `GET`, and
151+
/// `none` values for `path-with-query`, `scheme`, and `authority`.
152152
///
153-
/// * `method` represents the HTTP Method for the Request.
154-
/// * `path-with-query` is the combination of the HTTP Path and Query for
155-
/// the Request. When `none`, this represents an empty Path and empty
156-
/// Query.
157-
/// * `scheme` is the HTTP Related Scheme for the Request. When `none`,
158-
/// the implementation may choose an appropriate default scheme.
159-
/// * `authority` is the HTTP Authority for the Request. A value of `none`
160-
/// may be used with Related Schemes which do not require an Authority.
161-
/// The HTTP and HTTPS schemes always require an authority.
162153
/// * `headers` is the HTTP Headers for the Request.
163154
///
164155
/// It is possible to construct, or manipulate with the accessor functions
@@ -167,10 +158,6 @@ interface types {
167158
/// It is the obligation of the `outgoing-handler.handle` implementation
168159
/// to reject invalid constructions of `outgoing-request`.
169160
constructor(
170-
method: method,
171-
path-with-query: option<string>,
172-
scheme: option<scheme>,
173-
authority: option<string>,
174161
headers: headers
175162
);
176163

@@ -184,31 +171,35 @@ interface types {
184171

185172
/// Get the Method for the Request.
186173
method: func() -> method;
187-
/// Set the Method for the Request.
188-
set-method: func(method: method);
174+
/// Set the Method for the Request. Fails if the string present in a
175+
/// `method.other` argument is not a syntactically valid method.
176+
set-method: func(method: method) -> result;
189177

190178
/// Get the combination of the HTTP Path and Query for the Request.
191179
/// When `none`, this represents an empty Path and empty Query.
192180
path-with-query: func() -> option<string>;
193181
/// Set the combination of the HTTP Path and Query for the Request.
194-
/// When `none`, this represents an empty Path and empty Query.
195-
set-path-with-query: func(path-with-query: option<string>);
182+
/// When `none`, this represents an empty Path and empty Query. Fails is the
183+
/// string given is not a syntactically valid path and query uri component.
184+
set-path-with-query: func(path-with-query: option<string>) -> result;
196185

197186
/// Get the HTTP Related Scheme for the Request. When `none`, the
198187
/// implementation may choose an appropriate default scheme.
199188
scheme: func() -> option<scheme>;
200189
/// Set the HTTP Related Scheme for the Request. When `none`, the
201-
/// implementation may choose an appropriate default scheme.
202-
set-scheme: func(scheme: option<scheme>);
190+
/// implementation may choose an appropriate default scheme. Fails if the
191+
/// string given is not a syntactically valid uri scheme.
192+
set-scheme: func(scheme: option<scheme>) -> result;
203193

204194
/// Get the HTTP Authority for the Request. A value of `none` may be used
205195
/// with Related Schemes which do not require an Authority. The HTTP and
206196
/// HTTPS schemes always require an authority.
207197
authority: func() -> option<string>;
208198
/// Set the HTTP Authority for the Request. A value of `none` may be used
209199
/// with Related Schemes which do not require an Authority. The HTTP and
210-
/// HTTPS schemes always require an authority.
211-
set-authority: func(authority: option<string>);
200+
/// HTTPS schemes always require an authority. Fails if the string given is
201+
/// not a syntactically valid uri authority.
202+
set-authority: func(authority: option<string>) -> result;
212203

213204
/// Get the headers associated with the Request.
214205
///
@@ -223,7 +214,7 @@ interface types {
223214
/// transport layer of the HTTP protocol.
224215
///
225216
/// These timeouts are separate from any the user may use to bound a
226-
/// blocking call to `wasi:io/poll.poll-list`.
217+
/// blocking call to `wasi:io/poll.poll`.
227218
resource request-options {
228219
/// Construct a default `request-options` value.
229220
constructor();
@@ -351,16 +342,19 @@ interface types {
351342
/// Represents an outgoing HTTP Response.
352343
resource outgoing-response {
353344

354-
/// Construct an `outgoing-response`.
345+
/// Construct an `outgoing-response`, with a default `status-code` of `200`.
346+
/// If a different `status-code` is needed, it must be set via the
347+
/// `set-status-code` method.
355348
///
356-
/// * `status-code` is the HTTP Status Code for the Response.
357349
/// * `headers` is the HTTP Headers for the Response.
358-
constructor(status-code: status-code, headers: headers);
350+
constructor(headers: headers);
359351

360352
/// Get the HTTP Status Code for the Response.
361353
status-code: func() -> status-code;
362-
/// Set the HTTP Status Code for the Response.
363-
set-status-code: func(status-code: status-code);
354+
355+
/// Set the HTTP Status Code for the Response. Fails if the status-code
356+
/// given is not a valid http status code.
357+
set-status-code: func(status-code: status-code) -> result;
364358

365359
/// Get the headers associated with the Request.
366360
///

0 commit comments

Comments
 (0)