1use spin_factor_wasi::{FutureReaderExt as _, convert, convert_result, reborrow};
2use wasmtime::AsContextMut;
3use wasmtime::component::{Access, Accessor, FutureReader, Linker, Resource, StreamReader};
4use wasmtime_wasi_http::p3::{WasiHttp, WasiHttpCtxView, bindings as latest};
5
6mod bindings {
7 use super::latest;
8
9 wasmtime::component::bindgen!({
10 path: "../../wit",
11 world: "wasi:http/service@0.3.0-rc-2026-03-15",
12 imports: {
13 "wasi:http/client.send": store | trappable,
14 "wasi:http/types.[drop]request": store | trappable,
15 "wasi:http/types.[drop]response": store | trappable,
16 "wasi:http/types.[static]request.consume-body": store | trappable,
17 "wasi:http/types.[static]request.new": store | trappable,
18 "wasi:http/types.[static]response.consume-body": store | trappable,
19 "wasi:http/types.[static]response.new": store | trappable,
20 default: trappable,
21 },
22 exports: { default: async | store },
23 with: {
24 "wasi:http/types.fields": latest::http::types::Fields,
25 "wasi:http/types.request": latest::http::types::Request,
26 "wasi:http/types.request-options": latest::http::types::RequestOptions,
27 "wasi:http/types.response": latest::http::types::Response,
28 },
29 });
30}
31
32pub use bindings::{Service, ServiceIndices};
33
34mod wasi {
35 pub use super::bindings::wasi::http0_3_0_rc_2026_03_15 as http;
36}
37
38pub(crate) fn add_to_linker<T>(
39 linker: &mut Linker<T>,
40 closure: fn(&mut T) -> WasiHttpCtxView<'_>,
41) -> anyhow::Result<()>
42where
43 T: Send + 'static,
44{
45 wasi::http::types::add_to_linker::<_, WasiHttp>(linker, closure)?;
46 wasi::http::client::add_to_linker::<_, WasiHttp>(linker, closure)?;
47 Ok(())
48}
49
50impl wasi::http::types::Host for WasiHttpCtxView<'_> {}
51
52impl wasi::http::types::HostResponse for WasiHttpCtxView<'_> {
53 fn get_status_code(
54 &mut self,
55 res: Resource<wasi::http::types::Response>,
56 ) -> wasmtime::Result<wasi::http::types::StatusCode> {
57 latest::http::types::HostResponse::get_status_code(self, res)
58 }
59
60 fn set_status_code(
61 &mut self,
62 res: Resource<wasi::http::types::Response>,
63 status_code: wasi::http::types::StatusCode,
64 ) -> wasmtime::Result<Result<(), ()>> {
65 latest::http::types::HostResponse::set_status_code(self, res, status_code)
66 }
67
68 fn get_headers(
69 &mut self,
70 res: Resource<wasi::http::types::Response>,
71 ) -> wasmtime::Result<Resource<wasi::http::types::Headers>> {
72 latest::http::types::HostResponse::get_headers(self, res)
73 }
74}
75
76impl wasi::http::types::HostRequestOptions for WasiHttpCtxView<'_> {
77 fn new(&mut self) -> wasmtime::Result<Resource<wasi::http::types::RequestOptions>> {
78 latest::http::types::HostRequestOptions::new(self)
79 }
80
81 fn get_connect_timeout(
82 &mut self,
83 opts: Resource<wasi::http::types::RequestOptions>,
84 ) -> wasmtime::Result<Option<wasi::http::types::Duration>> {
85 latest::http::types::HostRequestOptions::get_connect_timeout(self, opts)
86 }
87
88 fn set_connect_timeout(
89 &mut self,
90 opts: Resource<wasi::http::types::RequestOptions>,
91 duration: Option<wasi::http::types::Duration>,
92 ) -> wasmtime::Result<Result<(), wasi::http::types::RequestOptionsError>> {
93 convert_result(
94 latest::http::types::HostRequestOptions::set_connect_timeout(self, opts, duration),
95 )
96 }
97
98 fn get_first_byte_timeout(
99 &mut self,
100 opts: Resource<wasi::http::types::RequestOptions>,
101 ) -> wasmtime::Result<Option<wasi::http::types::Duration>> {
102 latest::http::types::HostRequestOptions::get_first_byte_timeout(self, opts)
103 }
104
105 fn set_first_byte_timeout(
106 &mut self,
107 opts: Resource<wasi::http::types::RequestOptions>,
108 duration: Option<wasi::http::types::Duration>,
109 ) -> wasmtime::Result<Result<(), wasi::http::types::RequestOptionsError>> {
110 convert_result(
111 latest::http::types::HostRequestOptions::set_first_byte_timeout(self, opts, duration),
112 )
113 }
114
115 fn get_between_bytes_timeout(
116 &mut self,
117 opts: Resource<wasi::http::types::RequestOptions>,
118 ) -> wasmtime::Result<Option<wasi::http::types::Duration>> {
119 latest::http::types::HostRequestOptions::get_between_bytes_timeout(self, opts)
120 }
121
122 fn set_between_bytes_timeout(
123 &mut self,
124 opts: Resource<wasi::http::types::RequestOptions>,
125 duration: Option<wasi::http::types::Duration>,
126 ) -> wasmtime::Result<Result<(), wasi::http::types::RequestOptionsError>> {
127 convert_result(
128 latest::http::types::HostRequestOptions::set_between_bytes_timeout(
129 self, opts, duration,
130 ),
131 )
132 }
133
134 fn clone(
135 &mut self,
136 opts: Resource<wasi::http::types::RequestOptions>,
137 ) -> wasmtime::Result<Resource<wasi::http::types::RequestOptions>> {
138 latest::http::types::HostRequestOptions::clone(self, opts)
139 }
140
141 fn drop(&mut self, opts: Resource<wasi::http::types::RequestOptions>) -> wasmtime::Result<()> {
142 latest::http::types::HostRequestOptions::drop(self, opts)
143 }
144}
145
146impl<T> wasi::http::types::HostRequestWithStore<T> for WasiHttp {
147 fn new(
148 mut store: Access<T, Self>,
149 headers: Resource<wasi::http::types::Headers>,
150 contents: Option<StreamReader<u8>>,
151 trailers: FutureReader<
152 Result<Option<Resource<wasi::http::types::Trailers>>, wasi::http::types::ErrorCode>,
153 >,
154 options: Option<Resource<wasi::http::types::RequestOptions>>,
155 ) -> wasmtime::Result<(
156 Resource<wasi::http::types::Request>,
157 FutureReader<Result<(), wasi::http::types::ErrorCode>>,
158 )> {
159 let trailers = trailers.try_map(store.as_context_mut(), |v| v.map_err(|v| v.into()))?;
160 latest::http::types::HostRequestWithStore::new(
161 reborrow(&mut store),
162 headers,
163 contents,
164 trailers,
165 options,
166 )
167 .and_then(|(req, future)| Ok((req, future.try_map(store, |v| v.map_err(|v| v.into()))?)))
168 }
169
170 fn consume_body(
171 mut store: Access<T, Self>,
172 req: Resource<wasi::http::types::Request>,
173 fut: FutureReader<Result<(), wasi::http::types::ErrorCode>>,
174 ) -> wasmtime::Result<(
175 StreamReader<u8>,
176 FutureReader<
177 Result<Option<Resource<wasi::http::types::Trailers>>, wasi::http::types::ErrorCode>,
178 >,
179 )> {
180 let fut = fut.try_map(store.as_context_mut(), |v| v.map_err(|v| v.into()))?;
181 latest::http::types::HostRequestWithStore::consume_body(reborrow(&mut store), req, fut)
182 .and_then(|(stream, future)| {
183 Ok((stream, future.try_map(store, |v| v.map_err(|v| v.into()))?))
184 })
185 }
186
187 fn drop(
188 store: Access<'_, T, Self>,
189 req: Resource<wasi::http::types::Request>,
190 ) -> wasmtime::Result<()> {
191 latest::http::types::HostRequestWithStore::drop(store, req)
192 }
193}
194
195impl wasi::http::types::HostRequest for WasiHttpCtxView<'_> {
196 fn get_method(
197 &mut self,
198 req: Resource<wasi::http::types::Request>,
199 ) -> wasmtime::Result<wasi::http::types::Method> {
200 latest::http::types::HostRequest::get_method(self, req).map(|v| v.into())
201 }
202
203 fn set_method(
204 &mut self,
205 req: Resource<wasi::http::types::Request>,
206 method: wasi::http::types::Method,
207 ) -> wasmtime::Result<Result<(), ()>> {
208 latest::http::types::HostRequest::set_method(self, req, method.into())
209 }
210
211 fn get_path_with_query(
212 &mut self,
213 req: Resource<wasi::http::types::Request>,
214 ) -> wasmtime::Result<Option<String>> {
215 latest::http::types::HostRequest::get_path_with_query(self, req)
216 }
217
218 fn set_path_with_query(
219 &mut self,
220 req: Resource<wasi::http::types::Request>,
221 path_with_query: Option<String>,
222 ) -> wasmtime::Result<Result<(), ()>> {
223 latest::http::types::HostRequest::set_path_with_query(self, req, path_with_query)
224 }
225
226 fn get_scheme(
227 &mut self,
228 req: Resource<wasi::http::types::Request>,
229 ) -> wasmtime::Result<Option<wasi::http::types::Scheme>> {
230 latest::http::types::HostRequest::get_scheme(self, req).map(|v| v.map(|v| v.into()))
231 }
232
233 fn set_scheme(
234 &mut self,
235 req: Resource<wasi::http::types::Request>,
236 scheme: Option<wasi::http::types::Scheme>,
237 ) -> wasmtime::Result<Result<(), ()>> {
238 latest::http::types::HostRequest::set_scheme(self, req, scheme.map(|v| v.into()))
239 }
240
241 fn get_authority(
242 &mut self,
243 req: Resource<wasi::http::types::Request>,
244 ) -> wasmtime::Result<Option<String>> {
245 latest::http::types::HostRequest::get_authority(self, req)
246 }
247
248 fn set_authority(
249 &mut self,
250 req: Resource<wasi::http::types::Request>,
251 authority: Option<String>,
252 ) -> wasmtime::Result<Result<(), ()>> {
253 latest::http::types::HostRequest::set_authority(self, req, authority)
254 }
255
256 fn get_options(
257 &mut self,
258 req: Resource<wasi::http::types::Request>,
259 ) -> wasmtime::Result<Option<Resource<wasi::http::types::RequestOptions>>> {
260 latest::http::types::HostRequest::get_options(self, req)
261 }
262
263 fn get_headers(
264 &mut self,
265 req: Resource<wasi::http::types::Request>,
266 ) -> wasmtime::Result<Resource<wasi::http::types::Headers>> {
267 latest::http::types::HostRequest::get_headers(self, req)
268 }
269}
270
271impl wasi::http::types::HostFields for WasiHttpCtxView<'_> {
272 fn new(&mut self) -> wasmtime::Result<Resource<wasi::http::types::Fields>> {
273 latest::http::types::HostFields::new(self)
274 }
275
276 fn from_list(
277 &mut self,
278 entries: Vec<(wasi::http::types::FieldName, wasi::http::types::FieldValue)>,
279 ) -> wasmtime::Result<Result<Resource<wasi::http::types::Fields>, wasi::http::types::HeaderError>>
280 {
281 convert_result(latest::http::types::HostFields::from_list(self, entries))
282 }
283
284 fn get(
285 &mut self,
286 fields: Resource<wasi::http::types::Fields>,
287 name: wasi::http::types::FieldName,
288 ) -> wasmtime::Result<Vec<wasi::http::types::FieldValue>> {
289 latest::http::types::HostFields::get(self, fields, name)
290 }
291
292 fn has(
293 &mut self,
294 fields: Resource<wasi::http::types::Fields>,
295 name: wasi::http::types::FieldName,
296 ) -> wasmtime::Result<bool> {
297 latest::http::types::HostFields::has(self, fields, name)
298 }
299
300 fn set(
301 &mut self,
302 fields: Resource<wasi::http::types::Fields>,
303 name: wasi::http::types::FieldName,
304 value: Vec<wasi::http::types::FieldValue>,
305 ) -> wasmtime::Result<Result<(), wasi::http::types::HeaderError>> {
306 convert_result(latest::http::types::HostFields::set(
307 self, fields, name, value,
308 ))
309 }
310
311 fn delete(
312 &mut self,
313 fields: Resource<wasi::http::types::Fields>,
314 name: wasi::http::types::FieldName,
315 ) -> wasmtime::Result<Result<(), wasi::http::types::HeaderError>> {
316 convert_result(latest::http::types::HostFields::delete(self, fields, name))
317 }
318
319 fn get_and_delete(
320 &mut self,
321 fields: Resource<wasi::http::types::Fields>,
322 name: wasi::http::types::FieldName,
323 ) -> wasmtime::Result<Result<Vec<wasi::http::types::FieldValue>, wasi::http::types::HeaderError>>
324 {
325 convert_result(latest::http::types::HostFields::get_and_delete(
326 self, fields, name,
327 ))
328 }
329
330 fn append(
331 &mut self,
332 fields: Resource<wasi::http::types::Fields>,
333 name: wasi::http::types::FieldName,
334 value: wasi::http::types::FieldValue,
335 ) -> wasmtime::Result<Result<(), wasi::http::types::HeaderError>> {
336 convert_result(latest::http::types::HostFields::append(
337 self, fields, name, value,
338 ))
339 }
340
341 fn copy_all(
342 &mut self,
343 fields: Resource<wasi::http::types::Fields>,
344 ) -> wasmtime::Result<Vec<(wasi::http::types::FieldName, wasi::http::types::FieldValue)>> {
345 latest::http::types::HostFields::copy_all(self, fields)
346 }
347
348 fn clone(
349 &mut self,
350 fields: Resource<wasi::http::types::Fields>,
351 ) -> wasmtime::Result<Resource<wasi::http::types::Fields>> {
352 latest::http::types::HostFields::clone(self, fields)
353 }
354
355 fn drop(&mut self, fields: Resource<wasi::http::types::Fields>) -> wasmtime::Result<()> {
356 latest::http::types::HostFields::drop(self, fields)
357 }
358}
359
360impl<T> wasi::http::types::HostResponseWithStore<T> for WasiHttp {
361 fn new(
362 mut store: Access<T, Self>,
363 headers: Resource<wasi::http::types::Headers>,
364 contents: Option<StreamReader<u8>>,
365 trailers: FutureReader<
366 Result<Option<Resource<wasi::http::types::Trailers>>, wasi::http::types::ErrorCode>,
367 >,
368 ) -> wasmtime::Result<(
369 Resource<wasi::http::types::Response>,
370 FutureReader<Result<(), wasi::http::types::ErrorCode>>,
371 )> {
372 let trailers = trailers.try_map(store.as_context_mut(), |v| v.map_err(|v| v.into()))?;
373 latest::http::types::HostResponseWithStore::new(
374 reborrow(&mut store),
375 headers,
376 contents,
377 trailers,
378 )
379 .and_then(|(res, future)| Ok((res, future.try_map(store, |v| v.map_err(|v| v.into()))?)))
380 }
381
382 fn consume_body(
383 mut store: Access<T, Self>,
384 res: Resource<wasi::http::types::Response>,
385 fut: FutureReader<Result<(), wasi::http::types::ErrorCode>>,
386 ) -> wasmtime::Result<(
387 StreamReader<u8>,
388 FutureReader<
389 Result<Option<Resource<wasi::http::types::Trailers>>, wasi::http::types::ErrorCode>,
390 >,
391 )> {
392 let fut = fut.try_map(store.as_context_mut(), |v| v.map_err(|v| v.into()))?;
393 latest::http::types::HostResponseWithStore::consume_body(reborrow(&mut store), res, fut)
394 .and_then(|(stream, future)| {
395 Ok((stream, future.try_map(store, |v| v.map_err(|v| v.into()))?))
396 })
397 }
398
399 fn drop(
400 store: Access<'_, T, Self>,
401 res: Resource<wasi::http::types::Response>,
402 ) -> wasmtime::Result<()> {
403 latest::http::types::HostResponseWithStore::drop(store, res)
404 }
405}
406
407impl<T> wasi::http::client::HostWithStore<T> for WasiHttp {
408 async fn send(
409 store: &Accessor<T, Self>,
410 req: Resource<wasi::http::types::Request>,
411 ) -> wasmtime::Result<Result<Resource<wasi::http::types::Response>, wasi::http::types::ErrorCode>>
412 {
413 convert_result(latest::http::client::HostWithStore::send(store, req).await)
414 }
415}
416
417impl wasi::http::client::Host for WasiHttpCtxView<'_> {}
418
419convert! {
420 struct latest::http::types::DnsErrorPayload [<=>] wasi::http::types::DnsErrorPayload {
421 rcode,
422 info_code,
423 }
424
425 struct latest::http::types::TlsAlertReceivedPayload [<=>] wasi::http::types::TlsAlertReceivedPayload {
426 alert_id,
427 alert_message,
428 }
429
430 struct latest::http::types::FieldSizePayload [<=>] wasi::http::types::FieldSizePayload {
431 field_name,
432 field_size,
433 }
434
435 enum latest::http::types::RequestOptionsError => wasi::http::types::RequestOptionsError {
436 NotSupported,
437 Immutable,
438 Other(v),
439 }
440
441 enum latest::http::types::Method [<=>] wasi::http::types::Method {
442 Get,
443 Head,
444 Post,
445 Put,
446 Delete,
447 Connect,
448 Options,
449 Trace,
450 Patch,
451 Other(v),
452 }
453
454 enum latest::http::types::Scheme [<=>] wasi::http::types::Scheme {
455 Http,
456 Https,
457 Other(v),
458 }
459
460 enum latest::http::types::HeaderError [<=>] wasi::http::types::HeaderError {
461 InvalidSyntax,
462 Forbidden,
463 Immutable,
464 SizeExceeded,
465 Other(v),
466 }
467}
468
469impl From<wasi::http::types::ErrorCode> for latest::http::types::ErrorCode {
470 fn from(e: wasi::http::types::ErrorCode) -> Self {
471 match e {
472 wasi::http::types::ErrorCode::DnsTimeout => latest::http::types::ErrorCode::DnsTimeout,
473 wasi::http::types::ErrorCode::DnsError(e) => {
474 latest::http::types::ErrorCode::DnsError(e.into())
475 }
476 wasi::http::types::ErrorCode::DestinationNotFound => {
477 latest::http::types::ErrorCode::DestinationNotFound
478 }
479 wasi::http::types::ErrorCode::DestinationUnavailable => {
480 latest::http::types::ErrorCode::DestinationUnavailable
481 }
482 wasi::http::types::ErrorCode::DestinationIpProhibited => {
483 latest::http::types::ErrorCode::DestinationIpProhibited
484 }
485 wasi::http::types::ErrorCode::DestinationIpUnroutable => {
486 latest::http::types::ErrorCode::DestinationIpUnroutable
487 }
488 wasi::http::types::ErrorCode::ConnectionRefused => {
489 latest::http::types::ErrorCode::ConnectionRefused
490 }
491 wasi::http::types::ErrorCode::ConnectionTerminated => {
492 latest::http::types::ErrorCode::ConnectionTerminated
493 }
494 wasi::http::types::ErrorCode::ConnectionTimeout => {
495 latest::http::types::ErrorCode::ConnectionTimeout
496 }
497 wasi::http::types::ErrorCode::ConnectionReadTimeout => {
498 latest::http::types::ErrorCode::ConnectionReadTimeout
499 }
500 wasi::http::types::ErrorCode::ConnectionWriteTimeout => {
501 latest::http::types::ErrorCode::ConnectionWriteTimeout
502 }
503 wasi::http::types::ErrorCode::ConnectionLimitReached => {
504 latest::http::types::ErrorCode::ConnectionLimitReached
505 }
506 wasi::http::types::ErrorCode::TlsProtocolError => {
507 latest::http::types::ErrorCode::TlsProtocolError
508 }
509 wasi::http::types::ErrorCode::TlsCertificateError => {
510 latest::http::types::ErrorCode::TlsCertificateError
511 }
512 wasi::http::types::ErrorCode::TlsAlertReceived(e) => {
513 latest::http::types::ErrorCode::TlsAlertReceived(e.into())
514 }
515 wasi::http::types::ErrorCode::HttpRequestDenied => {
516 latest::http::types::ErrorCode::HttpRequestDenied
517 }
518 wasi::http::types::ErrorCode::HttpRequestLengthRequired => {
519 latest::http::types::ErrorCode::HttpRequestLengthRequired
520 }
521 wasi::http::types::ErrorCode::HttpRequestBodySize(e) => {
522 latest::http::types::ErrorCode::HttpRequestBodySize(e)
523 }
524 wasi::http::types::ErrorCode::HttpRequestMethodInvalid => {
525 latest::http::types::ErrorCode::HttpRequestMethodInvalid
526 }
527 wasi::http::types::ErrorCode::HttpRequestUriInvalid => {
528 latest::http::types::ErrorCode::HttpRequestUriInvalid
529 }
530 wasi::http::types::ErrorCode::HttpRequestUriTooLong => {
531 latest::http::types::ErrorCode::HttpRequestUriTooLong
532 }
533 wasi::http::types::ErrorCode::HttpRequestHeaderSectionSize(e) => {
534 latest::http::types::ErrorCode::HttpRequestHeaderSectionSize(e)
535 }
536 wasi::http::types::ErrorCode::HttpRequestHeaderSize(e) => {
537 latest::http::types::ErrorCode::HttpRequestHeaderSize(e.map(|e| e.into()))
538 }
539 wasi::http::types::ErrorCode::HttpRequestTrailerSectionSize(e) => {
540 latest::http::types::ErrorCode::HttpRequestTrailerSectionSize(e)
541 }
542 wasi::http::types::ErrorCode::HttpRequestTrailerSize(e) => {
543 latest::http::types::ErrorCode::HttpRequestTrailerSize(e.into())
544 }
545 wasi::http::types::ErrorCode::HttpResponseIncomplete => {
546 latest::http::types::ErrorCode::HttpResponseIncomplete
547 }
548 wasi::http::types::ErrorCode::HttpResponseHeaderSectionSize(e) => {
549 latest::http::types::ErrorCode::HttpResponseHeaderSectionSize(e)
550 }
551 wasi::http::types::ErrorCode::HttpResponseHeaderSize(e) => {
552 latest::http::types::ErrorCode::HttpResponseHeaderSize(e.into())
553 }
554 wasi::http::types::ErrorCode::HttpResponseBodySize(e) => {
555 latest::http::types::ErrorCode::HttpResponseBodySize(e)
556 }
557 wasi::http::types::ErrorCode::HttpResponseTrailerSectionSize(e) => {
558 latest::http::types::ErrorCode::HttpResponseTrailerSectionSize(e)
559 }
560 wasi::http::types::ErrorCode::HttpResponseTrailerSize(e) => {
561 latest::http::types::ErrorCode::HttpResponseTrailerSize(e.into())
562 }
563 wasi::http::types::ErrorCode::HttpResponseTransferCoding(e) => {
564 latest::http::types::ErrorCode::HttpResponseTransferCoding(e)
565 }
566 wasi::http::types::ErrorCode::HttpResponseContentCoding(e) => {
567 latest::http::types::ErrorCode::HttpResponseContentCoding(e)
568 }
569 wasi::http::types::ErrorCode::HttpResponseTimeout => {
570 latest::http::types::ErrorCode::HttpResponseTimeout
571 }
572 wasi::http::types::ErrorCode::HttpUpgradeFailed => {
573 latest::http::types::ErrorCode::HttpUpgradeFailed
574 }
575 wasi::http::types::ErrorCode::HttpProtocolError => {
576 latest::http::types::ErrorCode::HttpProtocolError
577 }
578 wasi::http::types::ErrorCode::LoopDetected => {
579 latest::http::types::ErrorCode::LoopDetected
580 }
581 wasi::http::types::ErrorCode::ConfigurationError => {
582 latest::http::types::ErrorCode::ConfigurationError
583 }
584 wasi::http::types::ErrorCode::InternalError(e) => {
585 latest::http::types::ErrorCode::InternalError(e)
586 }
587 }
588 }
589}
590
591impl From<latest::http::types::ErrorCode> for wasi::http::types::ErrorCode {
592 fn from(e: latest::http::types::ErrorCode) -> Self {
593 match e {
594 latest::http::types::ErrorCode::DnsTimeout => wasi::http::types::ErrorCode::DnsTimeout,
595 latest::http::types::ErrorCode::DnsError(e) => {
596 wasi::http::types::ErrorCode::DnsError(e.into())
597 }
598 latest::http::types::ErrorCode::DestinationNotFound => {
599 wasi::http::types::ErrorCode::DestinationNotFound
600 }
601 latest::http::types::ErrorCode::DestinationUnavailable => {
602 wasi::http::types::ErrorCode::DestinationUnavailable
603 }
604 latest::http::types::ErrorCode::DestinationIpProhibited => {
605 wasi::http::types::ErrorCode::DestinationIpProhibited
606 }
607 latest::http::types::ErrorCode::DestinationIpUnroutable => {
608 wasi::http::types::ErrorCode::DestinationIpUnroutable
609 }
610 latest::http::types::ErrorCode::ConnectionRefused => {
611 wasi::http::types::ErrorCode::ConnectionRefused
612 }
613 latest::http::types::ErrorCode::ConnectionTerminated => {
614 wasi::http::types::ErrorCode::ConnectionTerminated
615 }
616 latest::http::types::ErrorCode::ConnectionTimeout => {
617 wasi::http::types::ErrorCode::ConnectionTimeout
618 }
619 latest::http::types::ErrorCode::ConnectionReadTimeout => {
620 wasi::http::types::ErrorCode::ConnectionReadTimeout
621 }
622 latest::http::types::ErrorCode::ConnectionWriteTimeout => {
623 wasi::http::types::ErrorCode::ConnectionWriteTimeout
624 }
625 latest::http::types::ErrorCode::ConnectionLimitReached => {
626 wasi::http::types::ErrorCode::ConnectionLimitReached
627 }
628 latest::http::types::ErrorCode::TlsProtocolError => {
629 wasi::http::types::ErrorCode::TlsProtocolError
630 }
631 latest::http::types::ErrorCode::TlsCertificateError => {
632 wasi::http::types::ErrorCode::TlsCertificateError
633 }
634 latest::http::types::ErrorCode::TlsAlertReceived(e) => {
635 wasi::http::types::ErrorCode::TlsAlertReceived(e.into())
636 }
637 latest::http::types::ErrorCode::HttpRequestDenied => {
638 wasi::http::types::ErrorCode::HttpRequestDenied
639 }
640 latest::http::types::ErrorCode::HttpRequestLengthRequired => {
641 wasi::http::types::ErrorCode::HttpRequestLengthRequired
642 }
643 latest::http::types::ErrorCode::HttpRequestBodySize(e) => {
644 wasi::http::types::ErrorCode::HttpRequestBodySize(e)
645 }
646 latest::http::types::ErrorCode::HttpRequestMethodInvalid => {
647 wasi::http::types::ErrorCode::HttpRequestMethodInvalid
648 }
649 latest::http::types::ErrorCode::HttpRequestUriInvalid => {
650 wasi::http::types::ErrorCode::HttpRequestUriInvalid
651 }
652 latest::http::types::ErrorCode::HttpRequestUriTooLong => {
653 wasi::http::types::ErrorCode::HttpRequestUriTooLong
654 }
655 latest::http::types::ErrorCode::HttpRequestHeaderSectionSize(e) => {
656 wasi::http::types::ErrorCode::HttpRequestHeaderSectionSize(e)
657 }
658 latest::http::types::ErrorCode::HttpRequestHeaderSize(e) => {
659 wasi::http::types::ErrorCode::HttpRequestHeaderSize(e.map(|e| e.into()))
660 }
661 latest::http::types::ErrorCode::HttpRequestTrailerSectionSize(e) => {
662 wasi::http::types::ErrorCode::HttpRequestTrailerSectionSize(e)
663 }
664 latest::http::types::ErrorCode::HttpRequestTrailerSize(e) => {
665 wasi::http::types::ErrorCode::HttpRequestTrailerSize(e.into())
666 }
667 latest::http::types::ErrorCode::HttpResponseIncomplete => {
668 wasi::http::types::ErrorCode::HttpResponseIncomplete
669 }
670 latest::http::types::ErrorCode::HttpResponseHeaderSectionSize(e) => {
671 wasi::http::types::ErrorCode::HttpResponseHeaderSectionSize(e)
672 }
673 latest::http::types::ErrorCode::HttpResponseHeaderSize(e) => {
674 wasi::http::types::ErrorCode::HttpResponseHeaderSize(e.into())
675 }
676 latest::http::types::ErrorCode::HttpResponseBodySize(e) => {
677 wasi::http::types::ErrorCode::HttpResponseBodySize(e)
678 }
679 latest::http::types::ErrorCode::HttpResponseTrailerSectionSize(e) => {
680 wasi::http::types::ErrorCode::HttpResponseTrailerSectionSize(e)
681 }
682 latest::http::types::ErrorCode::HttpResponseTrailerSize(e) => {
683 wasi::http::types::ErrorCode::HttpResponseTrailerSize(e.into())
684 }
685 latest::http::types::ErrorCode::HttpResponseTransferCoding(e) => {
686 wasi::http::types::ErrorCode::HttpResponseTransferCoding(e)
687 }
688 latest::http::types::ErrorCode::HttpResponseContentCoding(e) => {
689 wasi::http::types::ErrorCode::HttpResponseContentCoding(e)
690 }
691 latest::http::types::ErrorCode::HttpResponseTimeout => {
692 wasi::http::types::ErrorCode::HttpResponseTimeout
693 }
694 latest::http::types::ErrorCode::HttpUpgradeFailed => {
695 wasi::http::types::ErrorCode::HttpUpgradeFailed
696 }
697 latest::http::types::ErrorCode::HttpProtocolError => {
698 wasi::http::types::ErrorCode::HttpProtocolError
699 }
700 latest::http::types::ErrorCode::LoopDetected => {
701 wasi::http::types::ErrorCode::LoopDetected
702 }
703 latest::http::types::ErrorCode::ConfigurationError => {
704 wasi::http::types::ErrorCode::ConfigurationError
705 }
706 latest::http::types::ErrorCode::InternalError(e) => {
707 wasi::http::types::ErrorCode::InternalError(e)
708 }
709 }
710 }
711}