diff --git a/crates/test-programs/src/bin/http_outbound_request_unknown_method.rs b/crates/test-programs/src/bin/http_outbound_request_unknown_method.rs index 8de9af2ca3ec..96101f9005a0 100644 --- a/crates/test-programs/src/bin/http_outbound_request_unknown_method.rs +++ b/crates/test-programs/src/bin/http_outbound_request_unknown_method.rs @@ -15,7 +15,7 @@ fn main() { .downcast::() .expect("expected a wasi-http ErrorCode"), ErrorCode::HttpRequestError(HttpRequestErrorPayload { - status_code: 405, + status_code: Some(405), .. }), )); diff --git a/crates/test-programs/src/bin/http_outbound_request_unsupported_scheme.rs b/crates/test-programs/src/bin/http_outbound_request_unsupported_scheme.rs index d7b59d891131..ffbf14f339cb 100644 --- a/crates/test-programs/src/bin/http_outbound_request_unsupported_scheme.rs +++ b/crates/test-programs/src/bin/http_outbound_request_unsupported_scheme.rs @@ -15,7 +15,7 @@ fn main() { .downcast::() .expect("expected a wasi-http ErrorCode"), ErrorCode::HttpRequestError(HttpRequestErrorPayload { - status_code: 400, + status_code: Some(400), .. }), )); diff --git a/crates/wasi-http/src/lib.rs b/crates/wasi-http/src/lib.rs index faa983c3d031..60b9dba1e750 100644 --- a/crates/wasi-http/src/lib.rs +++ b/crates/wasi-http/src/lib.rs @@ -39,8 +39,8 @@ pub mod bindings { pub(crate) fn dns_error(rcode: String, info_code: u16) -> bindings::http::types::ErrorCode { bindings::http::types::ErrorCode::DnsError(bindings::http::types::DnsErrorPayload { - rcode, - info_code, + rcode: Some(rcode), + info_code: Some(info_code), }) } @@ -50,8 +50,8 @@ pub(crate) fn http_request_error( ) -> bindings::http::types::ErrorCode { bindings::http::types::ErrorCode::HttpRequestError( bindings::http::types::HttpRequestErrorPayload { - status_code, - status_phrase, + status_code: Some(status_code), + status_phrase: Some(status_phrase), }, ) } diff --git a/crates/wasi-http/wit/deps/http/types.wit b/crates/wasi-http/wit/deps/http/types.wit index e4d88ab25ff9..2f744ba1f23c 100644 --- a/crates/wasi-http/wit/deps/http/types.wit +++ b/crates/wasi-http/wit/deps/http/types.wit @@ -27,8 +27,8 @@ interface types { other(string) } - // The cases of this variant correspond to the IANA HTTP Proxy Error Types: - // https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types + /// The cases of this variant correspond to the IANA HTTP Proxy Error Types: + /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types variant error-code { DNS-timeout, DNS-error(DNS-error-payload), @@ -48,13 +48,13 @@ interface types { HTTP-request-error(HTTP-request-error-payload), HTTP-request-denied, HTTP-response-incomplete, - HTTP-response-header-section-size(u32), + HTTP-response-header-section-size(option), HTTP-response-header-size(field-size-payload), - HTTP-response-body-size(u32), - HTTP-response-trailer-section-size(u32), + HTTP-response-body-size(option), + HTTP-response-trailer-section-size(option), HTTP-response-trailer-size(field-size-payload), - HTTP-response-transfer-coding(string), - HTTP-response-content-coding(string), + HTTP-response-transfer-coding(option), + HTTP-response-content-coding(option), HTTP-response-timeout, HTTP-upgrade-failed, HTTP-protocol-error, @@ -64,35 +64,28 @@ interface types { proxy-loop-detected } - // Defines the case payload type for `DNS-error` above: + /// Defines the case payload type for `DNS-error` above: record DNS-error-payload { - rcode: string, - info-code: u16 + rcode: option, + info-code: option } - // Defines the case payload type for `TLS-alert-received` above: + /// Defines the case payload type for `TLS-alert-received` above: record TLS-alert-received-payload { - alert-ID: u8, - alert-message: string + alert-ID: option, + alert-message: option } - // Defines the case payload type for `HTTP-request-error` above: + /// Defines the case payload type for `HTTP-request-error` above: record HTTP-request-error-payload { - status-code: u16, - status-phrase: string + status-code: option, + status-phrase: option } - // Defines the case payload type for `HTTP-response-{header,trailer}-size` above: + /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: record field-size-payload { - field-name: string, - field-size: u32 - } - - /// This tyep enumerates the different kinds of errors that may occur when - /// setting or appending to a `fields` resource. - variant header-error { - invalid-syntax, - forbidden, + field-name: option, + field-size: option } /// Attempts to extract a http-related `error` from the stream `error` @@ -107,6 +100,13 @@ interface types { /// are http-related errors. http-error: func(err: borrow) -> option; + /// This tyep enumerates the different kinds of errors that may occur when + /// setting or appending to a `fields` resource. + variant header-error { + invalid-syntax, + forbidden, + } + /// Field keys are always strings. type field-key = string; diff --git a/crates/wasi/wit/deps/http/types.wit b/crates/wasi/wit/deps/http/types.wit index e4d88ab25ff9..2f744ba1f23c 100644 --- a/crates/wasi/wit/deps/http/types.wit +++ b/crates/wasi/wit/deps/http/types.wit @@ -27,8 +27,8 @@ interface types { other(string) } - // The cases of this variant correspond to the IANA HTTP Proxy Error Types: - // https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types + /// The cases of this variant correspond to the IANA HTTP Proxy Error Types: + /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types variant error-code { DNS-timeout, DNS-error(DNS-error-payload), @@ -48,13 +48,13 @@ interface types { HTTP-request-error(HTTP-request-error-payload), HTTP-request-denied, HTTP-response-incomplete, - HTTP-response-header-section-size(u32), + HTTP-response-header-section-size(option), HTTP-response-header-size(field-size-payload), - HTTP-response-body-size(u32), - HTTP-response-trailer-section-size(u32), + HTTP-response-body-size(option), + HTTP-response-trailer-section-size(option), HTTP-response-trailer-size(field-size-payload), - HTTP-response-transfer-coding(string), - HTTP-response-content-coding(string), + HTTP-response-transfer-coding(option), + HTTP-response-content-coding(option), HTTP-response-timeout, HTTP-upgrade-failed, HTTP-protocol-error, @@ -64,35 +64,28 @@ interface types { proxy-loop-detected } - // Defines the case payload type for `DNS-error` above: + /// Defines the case payload type for `DNS-error` above: record DNS-error-payload { - rcode: string, - info-code: u16 + rcode: option, + info-code: option } - // Defines the case payload type for `TLS-alert-received` above: + /// Defines the case payload type for `TLS-alert-received` above: record TLS-alert-received-payload { - alert-ID: u8, - alert-message: string + alert-ID: option, + alert-message: option } - // Defines the case payload type for `HTTP-request-error` above: + /// Defines the case payload type for `HTTP-request-error` above: record HTTP-request-error-payload { - status-code: u16, - status-phrase: string + status-code: option, + status-phrase: option } - // Defines the case payload type for `HTTP-response-{header,trailer}-size` above: + /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: record field-size-payload { - field-name: string, - field-size: u32 - } - - /// This tyep enumerates the different kinds of errors that may occur when - /// setting or appending to a `fields` resource. - variant header-error { - invalid-syntax, - forbidden, + field-name: option, + field-size: option } /// Attempts to extract a http-related `error` from the stream `error` @@ -107,6 +100,13 @@ interface types { /// are http-related errors. http-error: func(err: borrow) -> option; + /// This tyep enumerates the different kinds of errors that may occur when + /// setting or appending to a `fields` resource. + variant header-error { + invalid-syntax, + forbidden, + } + /// Field keys are always strings. type field-key = string;