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,
|
|
|
|
};
|
|
|
|
|
2023-07-05 11:07:08 +08:00
|
|
|
// Console.WriteLine("--- 127.0.0.1:8090 ---");
|
2023-07-03 17:57:56 +08:00
|
|
|
|
2023-07-05 11:07:08 +08:00
|
|
|
// var resp = await client.GetAsync("https://127.0.0.1:8090/hello");
|
|
|
|
var resp = await client.GetAsync("https://api.hammer-hfut.tk:233/aics/file/hello");
|
2023-07-03 17:57:56 +08:00
|
|
|
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}"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|