fix other projects that use LoopbackServer
authorGeoff Kizer <geoffrek>
Mon, 11 Feb 2019 22:10:52 +0000 (14:10 -0800)
committerGeoff Kizer <geoffrek>
Mon, 11 Feb 2019 22:10:52 +0000 (14:10 -0800)
Commit migrated from https://github.com/dotnet/corefx/commit/700ca843faa9182dd9fa026abe7d409fa34ddb1c

src/libraries/Common/tests/System/Net/Http/GenericLoopbackServer.cs
src/libraries/Common/tests/System/Net/Http/Http2LoopbackServer.cs
src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs
src/libraries/System.Net.Requests/tests/System.Net.Requests.Tests.csproj
src/libraries/System.Net.WebClient/tests/System.Net.WebClient.Tests.csproj
src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj

index 98ccd93..ee3916b 100644 (file)
@@ -32,35 +32,6 @@ namespace System.Net.Test.Common
         }
     }
 
-    public sealed class Http11LoopbackServerFactory : LoopbackServerFactory
-    {
-        public static readonly Http11LoopbackServerFactory Singleton = new Http11LoopbackServerFactory();
-
-        public override Task CreateServerAsync(Func<GenericLoopbackServer, Uri, Task> funcAsync)
-        {
-            return LoopbackServer.CreateServerAsync((server, uri) => funcAsync(server, uri));
-        }
-
-        public override bool IsHttp11 => true;
-        public override bool IsHttp2 => false;
-    }
-
-    public sealed class Http2LoopbackServerFactory : LoopbackServerFactory
-    {
-        public static readonly Http2LoopbackServerFactory Singleton = new Http2LoopbackServerFactory();
-
-        public override async Task CreateServerAsync(Func<GenericLoopbackServer, Uri, Task> funcAsync)
-        {
-            using (var server = Http2LoopbackServer.CreateServer())
-            {
-                await funcAsync(server, server.Address);
-            }
-        }
-
-        public override bool IsHttp11 => false;
-        public override bool IsHttp2 => true;
-    }
-
     public abstract class GenericLoopbackServer : IDisposable
     {
         // Accept a new connection, process a single request and send the specified response, and gracefully close the connection.
index 8a20a6f..4e2e328 100644 (file)
@@ -632,4 +632,20 @@ namespace System.Net.Test.Common
         public bool UseSsl { get; set; } = true;
         public SslProtocols SslProtocols { get; set; } = SslProtocols.Tls12;
     }
+
+    public sealed class Http2LoopbackServerFactory : LoopbackServerFactory
+    {
+        public static readonly Http2LoopbackServerFactory Singleton = new Http2LoopbackServerFactory();
+
+        public override async Task CreateServerAsync(Func<GenericLoopbackServer, Uri, Task> funcAsync)
+        {
+            using (var server = Http2LoopbackServer.CreateServer())
+            {
+                await funcAsync(server, server.Address);
+            }
+        }
+
+        public override bool IsHttp11 => false;
+        public override bool IsHttp2 => true;
+    }
 }
index a2792b5..b52616b 100644 (file)
@@ -151,7 +151,7 @@ namespace System.Net.Test.Common
             var sep = new char[] { ':' };
             foreach (string line in headers)
             {
-                string[] tokens = line.Split(sep , 2);
+                string[] tokens = line.Split(sep, 2);
                 if (name.Equals(tokens[0], StringComparison.InvariantCultureIgnoreCase))
                 {
                     return tokens[1].Trim();
@@ -333,7 +333,7 @@ namespace System.Net.Test.Common
             "Transfer-Encoding: chunked\r\n" +
             additionalHeaders +
             "\r\n" +
-            (string.IsNullOrEmpty(content) ? "" : string.Concat(content.Select(c => $"1\r\n{c}\r\n"))) + 
+            (string.IsNullOrEmpty(content) ? "" : string.Concat(content.Select(c => $"1\r\n{c}\r\n"))) +
             $"0\r\n" +
             $"\r\n";
 
@@ -360,7 +360,7 @@ namespace System.Net.Test.Common
             public string Username { get; set; }
             public string Domain { get; set; }
             public string Password { get; set; }
-            public bool IsProxy  { get; set; } = false;
+            public bool IsProxy { get; set; } = false;
         }
 
         public sealed class Connection : IDisposable
@@ -475,11 +475,26 @@ namespace System.Net.Test.Common
             // Skip first line since it's the status line
             foreach (var line in headerLines.Skip(1))
             {
-                splits = line.Split(": ", 2);
-                requestData.Headers.Add(new HttpHeaderData(splits[0], splits[1]));
+                int offset = line.IndexOf(':');
+                string name = line.Substring(0, offset);
+                string value = line.Substring(offset + 1).TrimStart();
+                requestData.Headers.Add(new HttpHeaderData(name, value));
             }
 
             return requestData;
         }
     }
+
+    public sealed class Http11LoopbackServerFactory : LoopbackServerFactory
+    {
+        public static readonly Http11LoopbackServerFactory Singleton = new Http11LoopbackServerFactory();
+
+        public override Task CreateServerAsync(Func<GenericLoopbackServer, Uri, Task> funcAsync)
+        {
+            return LoopbackServer.CreateServerAsync((server, uri) => funcAsync(server, uri));
+        }
+
+        public override bool IsHttp11 => true;
+        public override bool IsHttp2 => false;
+    }
 }
index 9647829..926823c 100644 (file)
@@ -21,6 +21,9 @@
     <Compile Include="$(CommonTestPath)\System\Net\Http\LoopbackServer.cs">
       <Link>Common\System\Net\Http\LoopbackServer.cs</Link>
     </Compile>
+    <Compile Include="$(CommonTestPath)\System\Net\Http\GenericLoopbackServer.cs">
+      <Link>Common\System\Net\Http\GenericLoopbackServer.cs</Link>
+    </Compile>
     <Compile Include="$(CommonTestPath)\System\Threading\Tasks\TaskTimeoutExtensions.cs">
       <Link>Common\System\Threading\Tasks\TaskTimeoutExtensions.cs</Link>
     </Compile>
index eac2a6f..9e80861 100644 (file)
@@ -17,6 +17,9 @@
     <Compile Include="$(CommonTestPath)\System\Net\Http\LoopbackServer.cs">
       <Link>Common\System\Net\Http\LoopbackServer.cs</Link>
     </Compile>
+    <Compile Include="$(CommonTestPath)\System\Net\Http\GenericLoopbackServer.cs">
+      <Link>Common\System\Net\Http\GenericLoopbackServer.cs</Link>
+    </Compile>
     <Compile Include="$(CommonTestPath)\System\Threading\Tasks\TaskTimeoutExtensions.cs">
       <Link>Common\System\Threading\Tasks\TaskTimeoutExtensions.cs</Link>
     </Compile>
index ff38fe7..d101737 100644 (file)
@@ -30,6 +30,9 @@
     <Compile Include="$(CommonTestPath)\System\Net\Http\LoopbackServer.cs">
       <Link>Common\System\Net\Http\LoopbackServer.cs</Link>
     </Compile>
+    <Compile Include="$(CommonTestPath)\System\Net\Http\GenericLoopbackServer.cs">
+      <Link>Common\System\Net\Http\GenericLoopbackServer.cs</Link>
+    </Compile>
     <Compile Include="$(CommonTestPath)\System\Threading\Tasks\TaskTimeoutExtensions.cs">
       <Link>Common\System\Threading\Tasks\TaskTimeoutExtensions.cs</Link>
     </Compile>