Set proxy in Guzzle

后端 未结 6 484
广开言路
广开言路 2021-01-11 13:06

I have a problem with set proxy in guzzle that a blank page was shown while with curl everything works perfect. The code that I used in guzzle and curl came below. What is w

6条回答
  •  终归单人心
    2021-01-11 13:44

    The procedure for psr-7 may be different, but if you're using the standard way to instantiate a client,

    path\to\project\vendor\guzzlehttp\guzzle\src\Client.php, lines 164-170 includes code to read the environment variables to see if HTTP_PROXY and HTTPS_PROXY are set on the current machine, and if yes, Guzzle will use those values.

    Additionally, I had to set my HTTPS_PROXY = http://ip:port (not https), because our workplace proxy seems to handle both https and http requests via the http protocol.

    The advantage of this configuration is that you don't have to chnge proxy settings in your source code.

提交回复
热议问题