chilkat CkHttp c++:需要 Content-Length=0 使用 PUT 和 DELETE 动词
chilkat CkHttp c++ : need Content-Length=0 using PUT and DELETE verbs
我使用的是 Chilkat 9.5.0.75 x86-vc10-sp1(也在 9.5.0.76 上测试过)。
我需要使用一个 Web 服务,该服务还需要为具有空主体的 PUT 和 DELETE 调用指定 Content-Length。我从旧论坛上读到这个 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();
感谢您的任何建议
AddQuickHeader 已弃用,请改用 SetRequestHeader。
如果您将 Content-Length 显式设置为 0,则应将 "Content-Length: 0" header 添加到请求中。
http.SetRequestHeader("Content-Length","0");
通常您永远不会显式设置 Content-Length header,因为 Chilkat 会根据实际内容长度自动添加它(如果 non-zero)。
我使用的是 Chilkat 9.5.0.75 x86-vc10-sp1(也在 9.5.0.76 上测试过)。 我需要使用一个 Web 服务,该服务还需要为具有空主体的 PUT 和 DELETE 调用指定 Content-Length。我从旧论坛上读到这个 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();
感谢您的任何建议
AddQuickHeader 已弃用,请改用 SetRequestHeader。
如果您将 Content-Length 显式设置为 0,则应将 "Content-Length: 0" header 添加到请求中。
http.SetRequestHeader("Content-Length","0");
通常您永远不会显式设置 Content-Length header,因为 Chilkat 会根据实际内容长度自动添加它(如果 non-zero)。