POST HTTPs 请求的 GCP 监控中的预期正文内容
使用以下设置通过控制台设置 GCP 正常运行时间监控时,我收到 Request Exception in 10,000 ms
错误响应。 文档在正文部分提到“自己编码 URL”,我认为这是标准 URL 编码。
General
Request Method : POST
Body : %7B%20%22query%22%3A%20%22query%20%7B%20__typename%20%7D%22%20%7D
Host Header : application/x-www-form-urlencoded
Port : 443
Custom Headers
Header : Authorization
Value : Basic <hash token>
通过 curl
实现的等效效果如下例所示。
curl -X POST https://api.mytest.com \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Basic <hash token>' \
-d '{"query": "query { __typename }" }'
解释的正文部分很神秘,因为预期的内容应该是什么样子。我想知道是否有人得到了 POST 数据与正常运行时间良好配合的示例?
When setting up GCP uptime monitoring through the console with the following settings, I am getting a Request Exception in 10,000 ms
error response. The documentation mentions "encode URL yourself" on the body section, which I presume is a standard URL encode.
General
Request Method : POST
Body : %7B%20%22query%22%3A%20%22query%20%7B%20__typename%20%7D%22%20%7D
Host Header : application/x-www-form-urlencoded
Port : 443
Custom Headers
Header : Authorization
Value : Basic <hash token>
The equivalent via curl
which works would be as the following example.
curl -X POST https://api.mytest.com \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Basic <hash token>' \
-d '{"query": "query { __typename }" }'
The body section on explaining is cryptic as how the expected contents should be like. I am wondering if anyone did get an example of POST data working nicely with uptime?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于网址编码,您可以在此文档中了解如何构建要在 GCP 中使用的有效网址。这种 URL 的长度限制为 8192 个字符,请记住,在构建编码 URL 时,必须确保它仅包含有效字符,这在上一个文档中已提到。 在这里您可以找到一个可以帮助您对网址进行编码的工具。
此外,您可以尝试将“
响应超时”从默认的 10 秒增加到 30 秒或更长
。这是因为当您使用基于 URL 的正常运行时间检查时,URL 处的重定向需要更多时间。请注意,仔细检查您选择的目标协议(“http 或 https”)非常重要。此外,您还需要使用此命令nslookup + yourdomain.com
确保 URL 使用正确的 FQDN 进行应答,例如:Nslookup yourdomain.com
Regarding the URL encoding, you can find how to build a valid URL to be used in GCP in this document. This kind of URL is limited to 8192 characters, and please keep in mind that when you are building an encoded URL, you must ensure that it contains only valid characters, which are mentioned in the previous document. Here you can find a tool that could help you to encode your URL.
Additionally, you could try to increase the “
Response time out” from the default 10 sec to 30 sec or more
. This is because when you use an uptime check based on a URL, the redirections at the URL take more time. Please notice that it is very important to double-check the target protocol that you chose (“http or https”). Also, you need to be sure that the URL is answering with the proper FQDN using this commandnslookup + yourdomain.com
, for example:Nslookup yourdomain.com