@@ -8,10 +8,7 @@ like the baseURL, authentication details, and an embedded standard HTTP client.
88package httpclient
99
1010import (
11- "fmt"
1211 "net/http"
13- "net/http/cookiejar"
14- "net/url"
1512 "time"
1613
1714 "github.com/deploymenttheory/go-api-http-client/apiintegrations/apihandler"
@@ -159,10 +156,10 @@ func BuildClient(config ClientConfig) (*Client, error) {
159156 }
160157
161158 // Conditionally setup cookie jar
162- if err := SetupCookieJar (httpClient , config , log ); err != nil {
163- log .Error ("Error setting up cookie jar" , zap .Error (err ))
164- return nil , err
165- }
159+ // if err := SetupCookieJar(httpClient, config, log); err != nil {
160+ // log.Error("Error setting up cookie jar", zap.Error(err))
161+ // return nil, err
162+ // }
166163
167164 // Conditionally setup redirect handling
168165 if err := redirecthandler .SetupRedirectHandler (httpClient , config .ClientOptions .Redirect .FollowRedirects , config .ClientOptions .Redirect .MaxRedirects , log ); err != nil {
@@ -218,34 +215,35 @@ func BuildClient(config ClientConfig) (*Client, error) {
218215
219216}
220217
221- func SetupCookieJar (client * http.Client , clientConfig ClientConfig , log logger.Logger ) error {
222- if clientConfig .ClientOptions .Cookies .EnableCookieJar {
223- jar , err := cookiejar .New (nil ) // nil options use default options
224- if err != nil {
225- log .Error ("Failed to create cookie jar" , zap .Error (err ))
226- return fmt .Errorf ("setupCookieJar failed: %w" , err ) // Wrap and return the error
227- }
228-
229- if clientConfig .ClientOptions .Cookies .CustomCookies != nil {
230- var CookieList []* http.Cookie
231- CookieList = make ([]* http.Cookie , 0 )
232- for k , v := range clientConfig .ClientOptions .Cookies .CustomCookies {
233- newCookie := & http.Cookie {
234- Name : k ,
235- Value : v ,
236- }
237- CookieList = append (CookieList , newCookie )
238- }
239-
240- cookieUrl , err := url .Parse (fmt .Sprintf ("http://%s.jamfcloud.com" , clientConfig .Environment .InstanceName ))
241- if err != nil {
242- return err
243- }
244-
245- jar .SetCookies (cookieUrl , CookieList )
246- }
247-
248- client .Jar = jar
249- }
250- return nil
251- }
218+ // // SetupCookieJar sets up the cookie jar for the HTTP client if enabled in the configuration.
219+ // func SetupCookieJar(client *http.Client, clientConfig ClientConfig, log logger.Logger) error {
220+ // if clientConfig.ClientOptions.Cookies.EnableCookieJar {
221+ // jar, err := cookiejar.New(nil) // nil options use default options
222+ // if err != nil {
223+ // log.Error("Failed to create cookie jar", zap.Error(err))
224+ // return fmt.Errorf("setupCookieJar failed: %w", err) // Wrap and return the error
225+ // }
226+
227+ // if clientConfig.ClientOptions.Cookies.CustomCookies != nil {
228+ // var CookieList []*http.Cookie
229+ // CookieList = make([]*http.Cookie, 0)
230+ // for k, v := range clientConfig.ClientOptions.Cookies.CustomCookies {
231+ // newCookie := &http.Cookie{
232+ // Name: k,
233+ // Value: v,
234+ // }
235+ // CookieList = append(CookieList, newCookie)
236+ // }
237+
238+ // cookieUrl, err := url.Parse(fmt.Sprintf("http://%s.jamfcloud.com", clientConfig.Environment.InstanceName))
239+ // if err != nil {
240+ // return err
241+ // }
242+
243+ // jar.SetCookies(cookieUrl, CookieList)
244+ // }
245+
246+ // client.Jar = jar
247+ // }
248+ // return nil
249+ // }
0 commit comments