0

我正在使用 Chilkat 9.5.0.75 x86-vc10-sp1(并且也在 9.5.0.76 上测试过)。我需要使用需要为空主体的 PUT 和 DELETE 调用指定 Content-Length 的 web 服务。我从旧论坛阅读了这个http://www.chilkatforum.com/questions/5485/need-content-length0-http-header-even-when-message-is-empty/5528 ,但我仍然有这个问题。有什么解决方法吗?这就是我进行 PUT 调用的方式

CkHttp http;
if (!http.UnlockComponent(CK_UNLOCKCODE)) return false;
http.put_SessionLogFilename("http.txt");
http.AddQuickHeader("X-Authorization", authToken);
http.AddQuickHeader("Accept", "application/json");

CkString os;
http.QuickPutStr(endpoint, os);
int res = http.get_LastStatus();

谢谢你的任何建议

4

1 回答 1

0

AddQuickHeader 已弃用,请改用 SetRequestHeader。

如果您将 Content-Length 显式设置为 0,则应将“Content-Length:0”标头添加到请求中。

    http.SetRequestHeader("内容长度","0");

通常,您永远不会显式设置 Content-Length 标头,因为 Chilkat 会根据实际内容长度自动添加它(如果非零)。

于 2019-01-18T16:38:09.243 回答