今天早上我部署了自定义请求标头的更新版本后,自定义请求标头没有“到达”/被我的谷歌云功能接收。
备注:
为了确定是 Google Cloud Functions 造成的,我设置了一个新函数来测试这一点:
import functions_framework
from flask import make_response
@functions_framework.http
def hello_http(request):
print(request.headers)
response = make_response('Hello World')
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Headers'] = '*'
return response
这是我用来测试此问题/发送请求的Python脚本:
import requests
resp = requests.get("<google_cloud_function_url>/test-headers-1", headers = {
"custom_header_example" : "custom header value",
})
print(resp)
print(resp.headers)
最后,这些是云函数收到的标头(找不到custom_header_example)
如果有人知道导致此问题的原因,我将非常感谢您的帮助,我已经使用 GCP Cloud Functions 两年多了,从未出现过此问题,似乎这可能是 GCP 最近更改的内容