@@ -1650,19 +1650,28 @@ impl WasmInstanceEnv {
16501650 /// Perform an HTTP request as specified by the buffer `request_ptr[..request_len]`,
16511651 /// suspending execution until the request is complete,
16521652 /// then return its response details via a [`BytesSource`] written to `out[0]`
1653- /// and its response body via a [`BytesSource`] written to `out[1]`.
1653+ /// and its response body via another [`BytesSource`] written to `out[1]`.
16541654 ///
16551655 /// `request_ptr[..request_len]` should store a BSATN-serialized [`spacetimedb_lib::http::Request`] object
16561656 /// containing the details of the request to be performed.
16571657 ///
1658- /// `body_ptr[..body_len]` should store the body of the request to be performed;
1658+ /// `body_ptr[..body_len]` should store a byte array, which will be treated as the body of the request.
1659+ /// `body_ptr` should be non-null and within the bounds of linear memory even when `body_len` is 0.
1660+ ///
1661+ /// If the request is successful, a [`BytesSource`] is written to `out[0]`
1662+ /// containing a BSATN-encoded [`spacetimedb_lib::http::Response`] object,
1663+ /// another [`BytesSource`] containing the bytes of the response body are written to `out[1]`,
1664+ /// and this function returns 0.
16591665 ///
1660- /// If the request is successful, a [`BytesSource`] is written to `out`
1661- /// containing a BSATN-encoded [`spacetimedb_lib::http::Response`] object.
16621666 /// "Successful" in this context includes any connection which results in any HTTP status code,
16631667 /// regardless of the specified meaning of that code.
16641668 /// This includes HTTP error codes such as 404 Not Found and 500 Internal Server Error.
16651669 ///
1670+ /// If the request fails, a [`BytesSource`] is written to `out[0]`
1671+ /// containing a BSATN-encoded `String` describing the failure,
1672+ /// and this function returns `HTTP_ERROR`.
1673+ /// In this case, `out[1]` is not written.
1674+ ///
16661675 /// # Errors
16671676 ///
16681677 /// Returns an error:
@@ -1674,7 +1683,7 @@ impl WasmInstanceEnv {
16741683 /// In this case, `out` is not written.
16751684 /// - `HTTP_ERROR` if an error occurs while executing the HTTP request.
16761685 /// In this case, a [`BytesSource`] is written to `out`
1677- /// containing a BSATN-encoded [`spacetimedb_lib::http::Error`] object .
1686+ /// containing a BSATN-encoded [`String`] .
16781687 ///
16791688 /// # Traps
16801689 ///
@@ -1683,6 +1692,7 @@ impl WasmInstanceEnv {
16831692 /// - `request_ptr` is NULL or `request_ptr[..request_len]` is not in bounds of WASM memory.
16841693 /// - `body_ptr` is NULL or `body_ptr[..body_len]` is not in bounds of WASM memory.
16851694 /// - `out` is NULL or `out[..size_of::<RowIter>()]` is not in bounds of WASM memory.
1695+ /// - `request_ptr[..request_len]` does not contain a valid BSATN-serialized `spacetimedb_lib::http::Request` object.
16861696 pub fn procedure_http_request < ' caller > (
16871697 caller : Caller < ' caller , Self > ,
16881698 ( request_ptr, request_len, body_ptr, body_len, out) : ( WasmPtr < u8 > , u32 , WasmPtr < u8 > , u32 , WasmPtr < u32 > ) ,
0 commit comments