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
668 stars 133 forks source link

[Feature Request]: Provide an option to set default headers (and header orders) #68

Closed 3ldar closed 9 months ago

3ldar commented 11 months ago

Describe the feature / enhancement and how it would improve things

I didn't find the proper settings to set the headers in a client-wise fashion. (Like in C# HttpClients SetDefaultRequestHeaders) It allows you to set headers for the client's lifetime. Setting a header in a request level will override the default headers. If it is absent it would be nice to have such a feature.

Describe how your proposal will work, with code and/or pseudo-code

options := []tlsClient.HttpClientOption{
        tlsClient.WithTimeoutSeconds(30),
        tlsClient.WithClientProfile(tlsClient.MappedTLSClients[tlsIdentifier]),
        //tlsClient.WithDebug(),
        tlsClient.WithRandomTLSExtensionOrder(),
        tlsClient.WithProxyUrl(proxy),
        tlsClient.WithNotFollowRedirects(),
        tlsClient.WithInsecureSkipVerify(),
        tlsClient.WithCookieJar(jar),
        tlsClient.WithCatchPanics(),
                tlsClient.WithDefaultHeaders(someHeadersHere), // <--
    }
bogdanfinn commented 9 months ago

Introduced in version v1.6.0