-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into release/v1.19
- Loading branch information
Showing
11 changed files
with
273 additions
and
26 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
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
71 changes: 71 additions & 0 deletions
71
test/Fluxzy.Tests/UnitTests/RsBuffer/RequestProcessingBufferTests.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,71 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Fluxzy.Tests.UnitTests.RsBuffer | ||
{ | ||
public class RequestProcessingBufferTests | ||
{ | ||
[Theory] | ||
[MemberData(nameof(GetCheckBufferLimitArgs))] | ||
public async Task CheckAroundBufferLimit(int expectedSize) | ||
{ | ||
var setting = FluxzySetting.CreateLocalRandomPort(); | ||
var url = "https://sandbox.smartizy.com/ip"; | ||
|
||
var dummyHeaderName = ComputeProvisionalHeaderLength(url, out var headerSize); | ||
|
||
var count = 3; | ||
|
||
await using var proxy = new Proxy(setting); | ||
|
||
using var client = HttpClientUtility.CreateHttpClient(proxy.Run(), setting); | ||
|
||
var remainingBuffer = expectedSize - headerSize; | ||
|
||
var headerValue = new string('a', remainingBuffer); | ||
|
||
for (int i = 0; i < count; i++) { | ||
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url); | ||
requestMessage.Headers.TryAddWithoutValidation(dummyHeaderName, headerValue); | ||
|
||
var response = await client.SendAsync(requestMessage); | ||
var responseStream = await response.Content.ReadAsStreamAsync(); | ||
|
||
await responseStream.CopyToAsync(Stream.Null); | ||
|
||
Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
} | ||
} | ||
|
||
private static string ComputeProvisionalHeaderLength(string url, out int headerSize) | ||
{ | ||
var dummyHeaderName = "X-Padding"; | ||
|
||
headerSize = "GET HTTP/1.1\r\n\r\n\r\n".Length + "Host: \r\n".Length; | ||
|
||
headerSize += url.Length; | ||
headerSize += $"{dummyHeaderName}: \r\n".Length; | ||
|
||
return dummyHeaderName; | ||
} | ||
|
||
public static IEnumerable<object[]> GetCheckBufferLimitArgs() | ||
{ | ||
yield return new object[] { 500 }; | ||
yield return new object[] { 5192 }; | ||
|
||
var defaultBufferSize = FluxzySharedSetting.RequestProcessingBuffer; | ||
|
||
var marginCount = 32; | ||
|
||
for (int i = (defaultBufferSize - marginCount); i <= (defaultBufferSize + marginCount); i+=4) { | ||
|
||
yield return new object[] { i }; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.