IWEB_GetResponse返回status code:400?
以前没怎么做过网络相关,大家都帮忙看看向某网站进行POST数据,但需要进行认证,相关代码如下,返回的HTTP STATUS CODE为400,
查了下RFC1945,貌似entity body和Content-Length的设定有问题的话,会返回400
但是觉得看上去也没有什么问题。。。
摘自RFC1945
-----
If a requestcontains an entity body and Content-Length is not specified,
and the server does not recognize or cannot calculate the length
from other fields, then the server should send a 400 (bad request) response
-----
sample code
------------
//POST用IPEEK作成
ISOURCEUTIL_PeekFromMemory(pSourceUtil, pBuff, strlen(pBuff), ..., &pIPeek);
//HTTP "POST"
IWEB_GetResponse(pIWeb,(...,"www.xxx.com"
WEBOPT_METHOD, "POST",
WEBOPT_HEADER, "Authorization: Basic QWxhZGRpbjtZQ==", //authentication
WEBOPT_BODY, pIPeek, //set message to IPeek
WEBOPT_CONTENTLENGTH, strlen(pBuff), //length of message
...))
------------
难道说WEBOPT_CONTENTLENGTH的值不能用strlen(pBuff)?关于WEBOPT_CONTENTLENGTH --------------------编程问答-------------------- WEBOPT_HEADER可能也需要追加某种设定?不解。。。 --------------------编程问答-------------------- 用IWEB_GetResponse(pIweb, args) 这个试试看看。
Header不需要特殊设定吧
补充:移动开发 , Brew