【问题标题】:GAE PHP - URL Fetch [duplicate]GAE PHP - URL Fetch [重复]
【发布时间】:2014-03-09 19:29:38
【问题描述】:

根据调用另一个 App Engine 应用时的文档:

If you are making requests to another App Engine app, you should consider telling the UrlFetch service to not follow redirects when invoking it.

到目前为止,还没有关于如何编辑函数并告诉服务不要遵循重定向的文档,所以有人知道诀窍吗?

【问题讨论】:

    标签: google-app-engine


    【解决方案1】:

    你必须设置

    follow_redirects = false
    

    调用 fetch 时。

    使用 fetch 的标准调用

    fetch(url, payload=None, method=GET, headers={}, 
    allow_truncated=False, follow_redirects=True, deadline=5,
    validate_certificate=False)
    

    像这样将follow_redirects改为false

     fetch(url, payload=None, method=GET, headers={}, 
     allow_truncated=False, follow_redirects=False, deadline=5,
     validate_certificate=False)
    

    PHP

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

    【讨论】:

    • 我猜这是 Python 的,PHP 也一样吗?
    • 如果我没记错的话应该可以试试。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-15
    • 1970-01-01
    • 2021-03-25
    • 1970-01-01
    • 2016-06-03
    相关资源
    最近更新 更多