I've made Go code which sends http2 proxied request.
tlsConfig := &tls.Config{ MinVersion: tls.VersionTLS12, MaxVersion: tls.VersionTLS13, NextProtos: []string{"h2", "http/1.1"}, ServerName: u.Hostname(), InsecureSkipVerify: true, CipherSuites: selectedCipherSuites,}proxyURL, _ := url.Parse("http://" + proxy)client := &http.Client{ Timeout: time.Second * 10, Transport: &http.Transport{ Proxy: http.ProxyURL(proxyURL), TLSClientConfig: tlsConfig, ForceAttemptHTTP2: true, },}There is tls + ForceAttemptHTTP2, it sends http2 request to server. And in code it looks like this:
headers := req.Header headers.Set("Accept", acceptHeader) headers.Set("Accept-Encoding", acceptEncoding) headers.Set("X-Forwarded-For", ip) headers.Set("Accept-Language", acceptLanguage) headers.Set("Sec-Ch-Ua-Mobile", "?0") headers.Set("Sec-Ch-Ua-Platform", "\"Windows\"") headers.Set("Sec-Fetch-Dest", "document") headers.Set("Sec-Fetch-Mode", "navigate") headers.Set("Sec-Fetch-Site", "none") headers.Set("Sec-Fetch-User", "?1") headers.Set("Upgrade-Insecure-Requests", "1") headers.Set("User-Agent", userAgent)So I want order of headers to be like this cause of bot detections that cdn's have, so they dont block me. But when I tested, I have received headers this way:
Connection: Keep-AliveAccept-Encoding: gzip, brX-Forwarded-Proto: httpsSec-Ch-Ua-Mobile: ?0User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0Upgrade-Insecure-Requests: 1Accept: text/htmlSec-Fetch-Dest: documentAccept-Language: bn-BD,bn;q=0.8Sec-Fetch-Mode: navigateSec-Fetch-Site: noneSec-Ch-Ua-Platform: "Windows"Sec-Fetch-User: ?1So, it gets randomied, it's just one example, I recognized that every request it's different.And here is what exactly sends request.
req, err := http.NewRequest(method, target, nil) if err != nil { log.Fatal("Error creating request:", err) }+
response, err := client.Do(req) if err != nil { // fmt.Println("Došlo je do greške prilikom slanja zahteva:", err) return } defer response.Body.Close()I've tried everything that I could. Asked open ai to help but without any results.Also I've tried this https://go-review.googlesource.com/c/go/+/105755 but maybe it doesnt work for http2.
So, how to make order of headers to be in order which I wanted to be exactly while sending HTTP2 request with http/net library in Go, with TLS?