twitchax / AspNetCore.Proxy

ASP.NET Core Proxies made easy.
MIT License
505 stars 80 forks source link

Fix buffer handling for large WebSocket messages #88

Closed brnbs closed 2 years ago

brnbs commented 2 years ago

The original code seems to have issues when proxying large messages. Increasing the buffer size using WithBufferSize() helps, but it also significantly increases memory usage. This PR uses a dynamic-sized buffer using a MemoyStream.

AspNetCore.Proxy.Tests running fine and also tested with large JSON messages manually.

twitchax commented 2 years ago

LGTM, but would you mind adding a test with a large message?

codecov-commenter commented 2 years ago

Codecov Report

Merging #88 (6e9cf28) into master (572fc3e) will not change coverage. The diff coverage is 100.00%.

:exclamation: Current head 6e9cf28 differs from pull request most recent head 5d1ef86. Consider uploading reports for the commit 5d1ef86 to get more accurate results Impacted file tree graph

@@            Coverage Diff            @@
##            master       #88   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines          660       669    +9     
=========================================
+ Hits           660       669    +9     
Impacted Files Coverage Δ
src/Core/Extensions/Ws.cs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 572fc3e...5d1ef86. Read the comment docs.

brnbs commented 2 years ago

Added a test, please check and create a new release when you have some time :)