AicsKnowledgeBase_file/FileServerTests/UnitTest1.cs

30 lines
917 B
C#
Raw Normal View History

2023-07-03 17:57:56 +08:00
using System.Net;
using System.Text;
namespace FileServerTests;
public class UnitTest1 {
[Test]
public async Task TestMethod1() {
using var client = new HttpClient
{
DefaultRequestVersion = HttpVersion.Version30,
DefaultVersionPolicy = HttpVersionPolicy.RequestVersionExact,
};
Console.WriteLine("--- 127.0.0.1:8090 ---");
var resp = await client.GetAsync("https://127.0.0.1:8090/hello");
var headers = new StringBuilder();
foreach (var (headerName, headerValues) in resp.Headers) {
headers.AppendLine($"{headerName}: {string.Join(", ", headerValues)}");
}
var body = await resp.Content.ReadAsStringAsync();
Console.WriteLine(
$"status: {resp.StatusCode}, version: {resp.Version}, \n" +
$"headers: \n{headers}\n" +
$"body: \n{body}"
);
}
}