【问题标题】:Vibed: error: 411 Length RequiredVibed:错误:需要 411 长度
【发布时间】:2015-10-10 15:58:43
【问题描述】:

我正在尝试使用下一个代码获取服务器响应代码:

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,即“需要长度”。我做错了什么?

【问题讨论】:

    标签: http d http-status-codes vibed


    【解决方案1】:

    问题已通过以下方式解决: req.method = HTTPMethod.GET; 而不是 POST 方法。

    【讨论】:

    • 很可能是因为服务器期望POST 请求具有实际的正文和/或Content-Length 标头,而您在上面的示例中没有提供任何内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多