Skip to content

Fix AOT compatibility in streaming mode#128

Closed
Copilot wants to merge 3 commits intodevfrom
copilot/sub-pr-126
Closed

Fix AOT compatibility in streaming mode#128
Copilot wants to merge 3 commits intodevfrom
copilot/sub-pr-126

Conversation

Copy link
Contributor

Copilot AI commented Dec 3, 2025

Encoding.GetEncoding(charset) is not AOT-compatible due to runtime encoding provider lookup. Streaming mode now uses static Encoding.UTF8 to maintain AOT compatibility.

Changes

  • Replace dynamic Encoding.GetEncoding(charset) with Encoding.UTF8 in RequestExecutor.InvokeStreamingRequest
  • Update byte encoding to use Encoding.UTF8.GetBytes() consistently
-var encoding = responseMessage.Content.Headers.ContentType?.CharSet is { } charset
-    ? System.Text.Encoding.GetEncoding(charset)
-    : System.Text.Encoding.UTF8;
-using var reader = new StreamReader(stream, encoding);
+// Use UTF-8 encoding for AOT compatibility (Encoding.GetEncoding is not AOT-safe)
+using var reader = new StreamReader(stream, Encoding.UTF8);

Trade-off: Responses using non-UTF-8 encodings may not display correctly in streaming mode. This matches ResponseMapper behavior which also assumes UTF-8.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 3, 2025 10:03
Co-authored-by: WeihanLi <7604648+WeihanLi@users.noreply.github.com>
Co-authored-by: WeihanLi <7604648+WeihanLi@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 3, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • httpbin.org
    • Triggering command: /home/REDACTED/work/dotnet-httpie/dotnet-httpie/tests/HTTPie.IntegrationTest/bin/Debug/net10.0/HTTPie.IntegrationTest /home/REDACTED/work/dotnet-httpie/dotnet-httpie/tests/HTTPie.IntegrationTest/bin/Debug/net10.0/HTTPie.IntegrationTest --internal-msbuild-node /tmp/51ac26f264ff48b284bf0405fdb09839 (dns block)
  • reservation.weihanli.xyz
    • Triggering command: /home/REDACTED/work/dotnet-httpie/dotnet-httpie/tests/HTTPie.IntegrationTest/bin/Debug/net10.0/HTTPie.IntegrationTest /home/REDACTED/work/dotnet-httpie/dotnet-httpie/tests/HTTPie.IntegrationTest/bin/Debug/net10.0/HTTPie.IntegrationTest --internal-msbuild-node /tmp/51ac26f264ff48b284bf0405fdb09839 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update documentation and dependency management for dotnet-httpie Fix AOT compatibility in streaming mode Dec 3, 2025
Copilot AI requested a review from WeihanLi December 3, 2025 10:08
@WeihanLi WeihanLi closed this Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants