| 17 | } |
| 18 | |
| 19 | func InitTlsHTTPClient() { |
| 20 | jar := tls_client.NewCookieJar() |
| 21 | options := []tls_client.HttpClientOption{ |
| 22 | tls_client.WithTimeoutSeconds(360), |
| 23 | tls_client.WithClientProfile(profiles.Chrome_120), |
| 24 | tls_client.WithNotFollowRedirects(), |
| 25 | tls_client.WithCookieJar(jar), // create cookieJar instance and pass it as argument |
| 26 | } |
| 27 | client, _ := tls_client.NewHttpClient(tls_client.NewNoopLogger(), options...) |
| 28 | TlsHTTPClient = client |
| 29 | |
| 30 | HTTPClient = &http.Client{} |
| 31 | if common.Proxy != "" { |
| 32 | TlsHTTPClient.SetProxy(common.Proxy) |
| 33 | |
| 34 | u, err := url.Parse(common.Proxy) |
| 35 | if err != nil { |
| 36 | common.Logger.Error("Invalid proxy URL: " + common.Proxy) |
| 37 | panic(err) |
| 38 | } |
| 39 | HTTPClient = &http.Client{ |
| 40 | Transport: &http.Transport{ |
| 41 | Proxy: http.ProxyURL(u), |
| 42 | }, |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | func DoRequest(method, url string, body io.Reader, otherHeaders map[string]string) (*http.Response, error) { |
| 48 | headers := map[string]string{ |