-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wasi] wasi:http + WasiHttpHandler (#103752)
Co-authored-by: Joel Dice <joel.dice@fermyon.com>
- Loading branch information
1 parent
c0a31c5
commit 0e8db73
Showing
46 changed files
with
10,266 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
src/libraries/System.Net.Http/src/System/Net/Http/WasiHttpHandler/WasiHttp.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Generated by `wit-bindgen` 0.27.0. DO NOT EDIT! | ||
// <auto-generated /> | ||
#nullable enable | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Collections; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace WasiHttpWorld { | ||
|
||
internal interface IWasiHttpWorld { | ||
} | ||
|
||
internal readonly struct None {} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
internal readonly struct Result<Ok, Err> | ||
{ | ||
internal readonly byte Tag; | ||
private readonly object value; | ||
|
||
private Result(byte tag, object value) | ||
{ | ||
Tag = tag; | ||
this.value = value; | ||
} | ||
|
||
internal static Result<Ok, Err> ok(Ok ok) | ||
{ | ||
return new Result<Ok, Err>(OK, ok!); | ||
} | ||
|
||
internal static Result<Ok, Err> err(Err err) | ||
{ | ||
return new Result<Ok, Err>(ERR, err!); | ||
} | ||
|
||
internal bool IsOk => Tag == OK; | ||
internal bool IsErr => Tag == ERR; | ||
|
||
internal Ok AsOk | ||
{ | ||
get | ||
{ | ||
if (Tag == OK) | ||
return (Ok)value; | ||
else | ||
throw new ArgumentException("expected OK, got " + Tag); | ||
} | ||
} | ||
|
||
internal Err AsErr | ||
{ | ||
get | ||
{ | ||
if (Tag == ERR) | ||
return (Err)value; | ||
else | ||
throw new ArgumentException("expected ERR, got " + Tag); | ||
} | ||
} | ||
|
||
internal const byte OK = 0; | ||
internal const byte ERR = 1; | ||
} | ||
|
||
internal class Option<T> { | ||
private static Option<T> none = new (); | ||
|
||
private Option() | ||
{ | ||
HasValue = false; | ||
} | ||
|
||
internal Option(T v) | ||
{ | ||
HasValue = true; | ||
Value = v; | ||
} | ||
|
||
internal static Option<T> None => none; | ||
|
||
[MemberNotNullWhen(true, nameof(Value))] | ||
internal bool HasValue { get; } | ||
|
||
internal T? Value { get; } | ||
} | ||
|
||
internal static class InteropString | ||
{ | ||
internal static IntPtr FromString(string input, out int length) | ||
{ | ||
var utf8Bytes = Encoding.UTF8.GetBytes(input); | ||
length = utf8Bytes.Length; | ||
var gcHandle = GCHandle.Alloc(utf8Bytes, GCHandleType.Pinned); | ||
return gcHandle.AddrOfPinnedObject(); | ||
} | ||
} | ||
|
||
internal class WitException: Exception { | ||
internal object Value { get; } | ||
internal uint NestingLevel { get; } | ||
|
||
internal WitException(object v, uint level) | ||
{ | ||
Value = v; | ||
NestingLevel = level; | ||
} | ||
} | ||
|
||
namespace exports { | ||
internal static class WasiHttpWorld | ||
{ | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.