bogdanfinn / tls-client

net/http.Client like HTTP Client with options to select specific client TLS Fingerprints to use for requests.
BSD 4-Clause "Original" or "Old" License
667 stars 133 forks source link

How can I enable HTTP/2? #90

Open TangGV opened 6 months ago

TangGV commented 6 months ago

TLS client version

v1.7.0

System information

..

Issue description

client, _ := tls_client.NewHttpClient(tls_client.NewNoopLogger(), []tls_client.HttpClientOption{
    tls_client.WithCookieJar(tls_client.NewCookieJar()),
    tls_client.WithClientProfile(profiles.Safari_IOS_16_0),
    tls_client.WithTimeoutSeconds(500),
}...)

Steps to reproduce / Code Sample

client, _ := tls_client.NewHttpClient(tls_client.NewNoopLogger(), []tls_client.HttpClientOption{
    tls_client.WithCookieJar(tls_client.NewCookieJar()),
    tls_client.WithClientProfile(profiles.Safari_IOS_16_0),
    tls_client.WithTimeoutSeconds(500),
}...)
TangGV commented 6 months ago

req, err := http.NewRequest(c.Request.Method, requestURL, bytes.NewReader(requestBody))

client, _ := tls_client.NewHttpClient(tls_client.NewNoopLogger(), []tls_client.HttpClientOption{ tls_client.WithCookieJar(tls_client.NewCookieJar()), tls_client.WithClientProfile(profiles.Safari_IOS_16_0), tls_client.WithTimeoutSeconds(500), }...)

client.Do(req)

bogdanfinn commented 6 months ago

HTTP1/2 will be selected when the connection is created. It depends on your selected tls profile and of course the server. If both negotiate on http2 (and of course support it) it will be automatically used.