take HttpClient.BaseAddress into account when bounding request uri sizes
authorEirik Tsarpalis <eirik.tsarpalis@gmail.com>
Fri, 26 Jul 2019 20:40:48 +0000 (21:40 +0100)
committerEirik Tsarpalis <eirik.tsarpalis@gmail.com>
Fri, 26 Jul 2019 20:40:48 +0000 (21:40 +0100)
Commit migrated from https://github.com/dotnet/corefx/commit/d5a0fb96a026447dcf201dc7c19b0b8d41be60f5

src/libraries/System.Net.Http/tests/StressTests/HttpStress/ClientOperations.cs

index a4368bc..382e8f5 100644 (file)
@@ -48,6 +48,7 @@ namespace HttpStress
         public int MaxRequestParameters { get; }
         public int MaxRequestUriSize { get; }
         public int MaxContentLength => ContentSource.Length;
+        public Uri BaseAddress => _client.BaseAddress;
 
         // HttpClient.SendAsync() wrapper that wires randomized cancellation
         public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption httpCompletion = HttpCompletionOption.ResponseContentRead, CancellationToken? token = null)
@@ -417,7 +418,7 @@ namespace HttpStress
 
             var expectedString = new StringBuilder();
             var uriSb = new StringBuilder(uri);
-            maxRequestUriSize -= uri.Length;
+            maxRequestUriSize -= clientContext.BaseAddress.OriginalString.Length + uri.Length + 1;
 
             int appxMaxValueLength = Math.Max(maxRequestUriSize / numParameters, 1);