extism / dotnet-pdk

Extism Plug-in Development Kit (PDK) for C# and F#
https://extism.org
BSD 3-Clause "New" or "Revised" License
36 stars 6 forks source link

Headers not being sent with Pdk.SendRequest #83

Closed bradyjoslin closed 3 months ago

bradyjoslin commented 3 months ago

Code

  [UnmanagedCallersOnly(EntryPoint = "greet")]
  public static int Http_get()
  {
      // create an HTTP Request (withuot relying on WASI), set headers as needed
      var request = new HttpRequest("https://httpbin.org/headers")
      {
          Method = HttpMethod.GET,
      };
      request.Headers.Add("some-name", "some-value");
      request.Headers.Add("another", "again");
      var response = Pdk.SendRequest(request);
      Pdk.SetOutput(response.Body);
      return 0;
  }

Got

extism call ./bin/Debug/net8.0/wasi-wasm/AppBundle/Plugin.wasm greet \     
  --allow-host=httpbin.org --log-level=info --wasi   
{
  "headers": {
    "Accept-Encoding": "gzip", 
    "Host": "httpbin.org", 
    "User-Agent": "Go-http-client/2.0", 
    "X-Amzn-Trace-Id": "Root=1-*"
  }
}

Want

extism call ./bin/Debug/net8.0/wasi-wasm/AppBundle/Plugin.wasm greet \
  --allow-host=httpbin.org --log-level=info --wasi
{
  "headers": {
    "Accept-Encoding": "gzip", 
    "Another": "again", 
    "Host": "httpbin.org", 
    "Some-Name": "some-value", 
    "User-Agent": "Go-http-client/2.0", 
    "X-Amzn-Trace-Id": "Root=1-*"
  }
}

Isolated issue and tested locally, will submit PR.