我正在尝试使用下一个代码获取服务器响应代码:
import std.stdio;
import vibe.core.log;
import vibe.http.client;
import vibe.stream.operations;
import vibe.http.status;
void main()
{
requestHTTP("http://www.example.org/", (scope req) {
req.method = HTTPMethod.POST;
},
(scope res) {
logInfo("Response: %s", res.statusCode);
}
);
}
但我收到响应代码 411,这意味着“需要长度”。我做错了什么?
最佳答案
问题是通过以下方式解决的:
req.method = HTTPMethod.GET;
而不是 POST
方法。
关于http - Vibed:错误:411 需要长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33055916/