【问题标题】:400 Bad request with casablanca cpprestsdk400 与 casablanca cpprestsdk 的错误请求
【发布时间】:2017-03-10 23:12:10
【问题描述】:
  http_request request(methods::POST);
    request.headers().add(L"Content-Type", L"application/json; charset=utf-8");
    request.headers().add(L"X-Requested-With", L"XMLHttpRequest");
    request.set_body(body);

上面的代码给出以下输出:

HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 334
Content-Type: text/html; charset=us-ascii
Date: Fri, 10 Mar 2017 23:05:43 GMT
Server: Microsoft-HTTPAPI/2.0

你能告诉我我的参数有什么问题吗?

【问题讨论】:

    标签: c++ c++11 casablanca cpprest-sdk


    【解决方案1】:

    发现客户端试图在 localhost 上连接但使用其主机名。当更改客户端的配置以连接到 localhost:8088 而不是 degeneration:8088 时,它起作用了。所以是监听地址和目标地址不匹配。

    【讨论】: