tls-client icon indicating copy to clipboard operation
tls-client copied to clipboard

How can I enable HTTP/2?

Open TangGV opened this issue 1 year ago • 2 comments

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 avatar Dec 18 '23 04:12 TangGV

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)

TangGV avatar Dec 18 '23 04:12 TangGV

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.

bogdanfinn avatar Dec 18 '23 08:12 bogdanfinn