Skip to content

Commit 32da63e

Browse files
authored
Tweak a few fields docs (#99)
* Tweak a few `fields` docs - This patch clarifies the behavior of the various `fields` methods when syntactically invalid inputs are given. Some methods already noted this, but `get` in particular was missing a clarification that an invalid key would result in an empty list result - Removed some text in the doc for `from-list`. While non-UTF-8 values are not preferred for new applications, they are syntactically valid due to the [`obs-text` production](https://www.rfc-editor.org/rfc/rfc9110#section-5.5-2) in the RFC grammar. * regenerate markdown
1 parent 37b91f4 commit 32da63e

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

proxy.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,9 @@ http-related errors.</p>
745745
which have multiple values are represented by multiple entries in this
746746
list with the same key.</p>
747747
<p>The tuple is a pair of the field key, represented as a string, and
748-
Value, represented as a list of bytes. In a valid Fields, all keys
749-
and values are valid UTF-8 strings. However, values are not always
750-
well-formed, so they are represented as a raw list of bytes.</p>
751-
<p>An error result will be returned if any header or value was
752-
syntactically invalid, or if a header was forbidden.</p>
748+
Value, represented as a list of bytes.</p>
749+
<p>An error result will be returned if any <a href="#field_key"><code>field-key</code></a> or <a href="#field_value"><code>field-value</code></a> is
750+
syntactically invalid, or if a field is forbidden.</p>
753751
<h5>Params</h5>
754752
<ul>
755753
<li><a name="static_fields.from_list.entries"></a><code>entries</code>: 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>
@@ -760,9 +758,9 @@ syntactically invalid, or if a header was forbidden.</p>
760758
</ul>
761759
<h4><a name="method_fields.get"></a><code>[method]fields.get: func</code></h4>
762760
<p>Get all of the values corresponding to a key. If the key is not present
763-
in this <a href="#fields"><code>fields</code></a>, an empty list is returned. However, if the key is
764-
present but empty, this is represented by a list with one or more
765-
empty field-values present.</p>
761+
in this <a href="#fields"><code>fields</code></a> or is syntactically invalid, an empty list is returned.
762+
However, if the key is present but empty, this is represented by a list
763+
with one or more empty field-values present.</p>
766764
<h5>Params</h5>
767765
<ul>
768766
<li><a name="method_fields.get.self"></a><code>self</code>: borrow&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>
@@ -788,6 +786,8 @@ syntactically invalid, <code>false</code> is returned.</p>
788786
<p>Set all of the values for a key. Clears any existing values for that
789787
key, if they have been set.</p>
790788
<p>Fails with <code>header-error.immutable</code> if the <a href="#fields"><code>fields</code></a> are immutable.</p>
789+
<p>Fails with <code>header-error.invalid-syntax</code> if the <a href="#field_key"><code>field-key</code></a> or any of
790+
the <a href="#field_value"><code>field-value</code></a>s are syntactically invalid.</p>
791791
<h5>Params</h5>
792792
<ul>
793793
<li><a name="method_fields.set.self"></a><code>self</code>: borrow&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>
@@ -802,6 +802,8 @@ key, if they have been set.</p>
802802
<p>Delete all values for a key. Does nothing if no values for the key
803803
exist.</p>
804804
<p>Fails with <code>header-error.immutable</code> if the <a href="#fields"><code>fields</code></a> are immutable.</p>
805+
<p>Fails with <code>header-error.invalid-syntax</code> if the <a href="#field_key"><code>field-key</code></a> is
806+
syntactically invalid.</p>
805807
<h5>Params</h5>
806808
<ul>
807809
<li><a name="method_fields.delete.self"></a><code>self</code>: borrow&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>
@@ -815,6 +817,8 @@ exist.</p>
815817
<p>Append a value for a key. Does not change or delete any existing
816818
values for that key.</p>
817819
<p>Fails with <code>header-error.immutable</code> if the <a href="#fields"><code>fields</code></a> are immutable.</p>
820+
<p>Fails with <code>header-error.invalid-syntax</code> if the <a href="#field_key"><code>field-key</code></a> or
821+
<a href="#field_value"><code>field-value</code></a> are syntactically invalid.</p>
818822
<h5>Params</h5>
819823
<ul>
820824
<li><a name="method_fields.append.self"></a><code>self</code>: borrow&lt;<a href="#fields"><a href="#fields"><code>fields</code></a></a>&gt;</li>

wit/types.wit

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,18 @@ interface types {
159159
/// list with the same key.
160160
///
161161
/// The tuple is a pair of the field key, represented as a string, and
162-
/// Value, represented as a list of bytes. In a valid Fields, all keys
163-
/// and values are valid UTF-8 strings. However, values are not always
164-
/// well-formed, so they are represented as a raw list of bytes.
162+
/// Value, represented as a list of bytes.
165163
///
166-
/// An error result will be returned if any header or value was
167-
/// syntactically invalid, or if a header was forbidden.
164+
/// An error result will be returned if any `field-key` or `field-value` is
165+
/// syntactically invalid, or if a field is forbidden.
168166
from-list: static func(
169167
entries: list<tuple<field-key,field-value>>
170168
) -> result<fields, header-error>;
171169

172170
/// Get all of the values corresponding to a key. If the key is not present
173-
/// in this `fields`, an empty list is returned. However, if the key is
174-
/// present but empty, this is represented by a list with one or more
175-
/// empty field-values present.
171+
/// in this `fields` or is syntactically invalid, an empty list is returned.
172+
/// However, if the key is present but empty, this is represented by a list
173+
/// with one or more empty field-values present.
176174
get: func(name: field-key) -> list<field-value>;
177175

178176
/// Returns `true` when the key is present in this `fields`. If the key is
@@ -183,18 +181,27 @@ interface types {
183181
/// key, if they have been set.
184182
///
185183
/// Fails with `header-error.immutable` if the `fields` are immutable.
184+
///
185+
/// Fails with `header-error.invalid-syntax` if the `field-key` or any of
186+
/// the `field-value`s are syntactically invalid.
186187
set: func(name: field-key, value: list<field-value>) -> result<_, header-error>;
187188

188189
/// Delete all values for a key. Does nothing if no values for the key
189190
/// exist.
190191
///
191192
/// Fails with `header-error.immutable` if the `fields` are immutable.
193+
///
194+
/// Fails with `header-error.invalid-syntax` if the `field-key` is
195+
/// syntactically invalid.
192196
delete: func(name: field-key) -> result<_, header-error>;
193197

194198
/// Append a value for a key. Does not change or delete any existing
195199
/// values for that key.
196200
///
197201
/// Fails with `header-error.immutable` if the `fields` are immutable.
202+
///
203+
/// Fails with `header-error.invalid-syntax` if the `field-key` or
204+
/// `field-value` are syntactically invalid.
198205
append: func(name: field-key, value: field-value) -> result<_, header-error>;
199206

200207
/// Retrieve the full set of keys and values in the Fields. Like the

0 commit comments

Comments
 (0)