Setting up proxy for HTTP client

后端 未结 5 2058
抹茶落季
抹茶落季 2020-12-12 18:15

I\'m trying to setup the HTTP client so that it uses a proxy, however I cannot quite understand how to do it. The documentation has multiple reference to \"proxy\" but none

5条回答
  •  囚心锁ツ
    2020-12-12 18:41

    For an alternative way, you can also use GoRequest which has a feature that you can set proxy easily for any single request.

    request := gorequest.New()
    resp, body, errs:= request.Proxy("http://proxy:999").Get("http://example.com").End()
    resp2, body2, errs2 := request.Proxy("http://proxy2:999").Get("http://example2.com").End()
    

    Or you can set for the whole at once.

    request := gorequest.New().Proxy("http://proxy:999")
    resp, body, errs:= request.Get("http://example.com").End()
    resp2, body2, errs2 := request.Get("http://example2.com").End()
    

提交回复
热议问题