}
}
- 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.
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;
+ }
}
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();
"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";
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
// 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;
+ }
}
<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>
<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>
<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>