Skip to content

Commit ae8d699

Browse files
committed
docs: update example project
1 parent a998c11 commit ae8d699

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

examples/Program.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,22 @@
88

99
internal class Program
1010
{
11-
private const string PATH_LIB = "Native\\tls-client-windows-64-1.11.0.dll";
12-
1311
private static void Main()
1412
{
15-
//BasicGetRequest();
16-
//PostJsonRequest();
17-
//CookieHandling();
18-
//HeadersAndProxy();
19-
ErrorHandlingAndTimeouts();
13+
Http2Client.Http2Client.Initialize("Native\\tls-client-windows-64-1.11.0.dll");
14+
15+
try
16+
{
17+
BasicGetRequest();
18+
PostJsonRequest();
19+
CookieHandling();
20+
HeadersAndProxy();
21+
ErrorHandlingAndTimeouts();
22+
}
23+
finally
24+
{
25+
Http2Client.Http2Client.Cleanup();
26+
}
2027

2128
Console.ReadLine();
2229
}
@@ -27,7 +34,6 @@ private static void BasicGetRequest()
2734

2835
using var client = new HttpClientBuilder()
2936
.WithUserAgent("Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36")
30-
.WithLibraryPath(PATH_LIB)
3137
.WithRandomTlsExtensions()
3238
.Build();
3339

@@ -50,7 +56,6 @@ private static void PostJsonRequest()
5056

5157
using var client = new HttpClientBuilder()
5258
.WithUserAgent("Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36")
53-
.WithLibraryPath(PATH_LIB)
5459
.WithHeader("Content-Type", "application/json")
5560
.WithCookies()
5661
.Build();
@@ -83,7 +88,6 @@ private static void CookieHandling()
8388

8489
using var client = new HttpClientBuilder()
8590
.WithUserAgent("Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36")
86-
.WithLibraryPath(PATH_LIB)
8791
.WithCookies(true)
8892
.Build();
8993

@@ -118,7 +122,6 @@ private static void HeadersAndProxy()
118122

119123
using var client = new HttpClientBuilder()
120124
.WithUserAgent("Custom-Agent/1.0")
121-
.WithLibraryPath(PATH_LIB)
122125
.WithHeader("Accept", "application/json")
123126
.WithHeader("Accept-Language", "en-US,en;q=0.9")
124127
.WithHeader("Accept-Encoding", "gzip, deflate, br")
@@ -150,7 +153,6 @@ private static void ErrorHandlingAndTimeouts()
150153

151154
using var client = new HttpClientBuilder()
152155
.WithUserAgent("Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36")
153-
.WithLibraryPath(PATH_LIB)
154156
.WithTimeout(TimeSpan.FromSeconds(10))
155157
.WithCatchPanics(true)
156158
.WithInsecureSkipVerify(false)

0 commit comments

Comments
 (0)