How to disable redirects when doing a URLFetch in PHP for Google App Engine?

后端 未结 1 1017
别跟我提以往
别跟我提以往 2021-01-28 19:31

I\'m trying to set up two PHP on GAE sites: One to act as a web services layer, and another to act as the front-end. So far, things are great. I\'m trying to secure communicatio

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-28 20:15

    Two ways, either set follow_location to false and/or max_redirects to 0.

    $context = [
        'http' => [
        'method' => 'get',
        'header' => "custom-header: custom-value\r\n" . "custom-header-two: custome-value-2\r\n",
        'content' => $data,
        'follow_location' => false,
        ]
    ];
    

    or

    $context = [
        'http' => [
        'method' => 'get',
        'header' => "custom-header: custom-value\r\n" . "custom-header-two: custome-value-2\r\n",
        'content' => $data,
        'max_redirects' => 0,
        ]
    ];
    

    0 讨论(0)
提交回复
热议问题