@@ -32,13 +32,16 @@ Http2Client requires the native TLS library from the original [bogdanfinn/tls-cl
3232** Installation Instructions:**
3333
34341 . Download the appropriate library file for your platform from the table above
35- 2 . Place the native library in your application's output directory, or
36- 3 . Specify the custom path using the ` WithLibraryPath ()` method in your code
35+ 2 . Place the native library in your application's output directory, or specify a custom path
36+ 3 . Initialize the library once at application startup using ` Http2Client.Initialize ()`
3737
3838** Example for Windows:**
3939``` csharp
40+ // Initialize once at application startup
41+ Http2Client .Initialize (" tls-client-windows-64-1.11.0.dll" );
42+
43+ // Create clients as needed
4044using var client = new HttpClientBuilder ()
41- .WithLibraryPath (" tls-client-windows-64-1.11.0.dll" )
4245 .Build ();
4346```
4447
@@ -56,9 +59,11 @@ using Http2Client.Builders;
5659using Http2Client .Core .Enums ;
5760using Http2Client .Core .Request ;
5861
62+ // Initialize native library once at application startup
63+ Http2Client .Initialize (" tls-client-windows-64-1.11.0.dll" );
64+
5965// Create an Http2Client instance using the builder
6066using var client = new HttpClientBuilder ()
61- .WithLibraryPath (" tls-client-windows-64-1.11.0.dll" )
6267 .WithBrowserType (BrowserType .Chrome133 )
6368 .WithUserAgent (" Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" )
6469 .WithTimeout (TimeSpan .FromSeconds (30 ))
@@ -118,7 +123,6 @@ using var client = new HttpClientBuilder()
118123
119124| Method | Description |
120125| --------| -------------|
121- | ` WithLibraryPath(string) ` | Sets the path to the native TLS library. |
122126| ` WithBrowserType(BrowserType) ` | Sets the browser fingerprint to mimic. |
123127| ` WithUserAgent(string) ` | Sets the User-Agent header. |
124128| ` WithTimeout(TimeSpan) ` | Sets the request timeout. |
@@ -142,8 +146,10 @@ using var client = new HttpClientBuilder()
142146### Advanced Example
143147
144148``` csharp
149+ // Initialize library once at startup
150+ Http2Client .Initialize (" tls-client-windows-64-1.11.0.dll" );
151+
145152using var client = new HttpClientBuilder ()
146- .WithLibraryPath (" tls-client-windows-64-1.11.0.dll" )
147153 .WithBrowserType (BrowserType .Firefox132 )
148154 .WithUserAgent (" Mozilla/5.0 (Windows NT 10.0; Win64; x64)" )
149155 .WithProxy (" http://127.0.0.1:8888" , isRotating : true )
@@ -228,7 +234,6 @@ var request = new HttpRequest
228234
229235``` csharp
230236using var client = new HttpClientBuilder ()
231- .WithLibraryPath (" tls-client-windows-64-1.11.0.dll" )
232237 .WithBrowserType (BrowserType .Chrome133 )
233238 .Build ();
234239
@@ -265,7 +270,6 @@ var response = client.Send(request);
265270
266271``` csharp
267272using var client = new HttpClientBuilder ()
268- .WithLibraryPath (" tls-client-windows-64-1.11.0.dll" )
269273 .WithBrowserType (BrowserType .Chrome133 )
270274 .WithProxy (" http://proxy.example.com:8080" )
271275 .Build ();
0 commit comments