MSN登录问题(https协议)
在登录MSN时,登录验证总是过不去.
具体是在https协议发送请求时.有一些东西发出去以后,返回数据不对.
具体例子及协议链接:
http://www.hypothetic.org/docs/msn/notification/authentication-example.php
问题在:USR 3 TWN I之后,前面一切顺利
在nexus.passport.com上用https取得数据正确.(这步标志为A)
在login.passport.com上数据总数不正确,返回HTTP/1.1 404(请求页面不能发现)(这步标志为B)
A和B的区别:
A只发一个:GET /rdr/pprdr.asp HTTP/1.0\r\n
B发送数据:GET /login2.srf HTTP/1.1\r\n
还有类似如下数据: Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in=example%40passport.com,pwd=password,lc=1033,id=507,tw=40,fs=1,ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=1062764229,kpp=1,kv=5,ver=2.1.0173.1,tpf=43f8a4c8ed940c04e3740be46c4d1619\r\n
Host: login.passport.com\r\n
代码如下(各位大虾帮我看看有什么问题):
static LPCTSTR szAcceptType=TEXT(__HTTP_ACCEPT_TYPE);
if(!_hConnection || _hConnection==INVALID_HANDLE_VALUE)
throw "handle not opened...";
_hRequest=::HttpOpenRequest( _hConnection, //_hConnection已经正常打开
__HTTP_VERB_GET, // HTTP Verb
szuri, // Object Name (我在这里放入GET /login2.srf HTTP/1.1\r\n)
HTTP_VERSION, // Version
szref, // Reference
&szAcceptType, // Accept Type
INTERNET_FLAG_NO_CACHE_WRITE | (_t==w3https? INTERNET_FLAG_SECURE:0),
NULL); // context call-back point
if(!_hRequest || _hRequest==INVALID_HANDLE_VALUE)
throw "request failed...";
char szTmpHeadData[2048] = { 0 };
strcpy( szTmpHeadData , HeaderData1 );
// if(!::HttpAddRequestHeaders( _hRequest,
// __HTTP_ACCEPT, strlen(__HTTP_ACCEPT),
// HTTP_ADDREQ_FLAG_REPLACE))
// printf( "错了1\r\n" );
if(!::HttpAddRequestHeaders( _hRequest,
szTmpHeadData, strlen(szTmpHeadData), //我在这里放入: Authorization: Pa...
HTTP_ADDREQ_FLAG_COALESCE))
printf( "错了2\r\n" );
memset( szTmpHeadData , 0 , 2048 );
strcpy( szTmpHeadData , HeaderData2 );
if(!::HttpAddRequestHeaders( _hRequest,
szTmpHeadData, strlen(szTmpHeadData), //我在这里放入: Host: login.passport.com\r\n
HTTP_ADDREQ_FLAG_COALESCE))
printf( "错了3\r\n" );
// REPLACE HEADER
//if(!::HttpAddRequestHeaders( _hRequest,
// __HTTP_ACCEPT, strlen(__HTTP_ACCEPT),
// HTTP_ADDREQ_FLAG_REPLACE))
// throw "additional header failed...";
// SEND REQUEST
if(!::HttpSendRequest( _hRequest, // handle by returned HttpOpenRequest
NULL, // additional HTTP header
0, // additional HTTP header length
NULL, // additional data in HTTP Post or HTTP Put
0) // additional data length
)
throw "request failed...";
_szuri=szuri;
}catch(const char *szm){
::InternetCloseHandle(_hRequest);
_hRequest=NULL;
__w3cexcept(_szaddress.c_str(), _nport, _t, szuri, szm);
}catch(...){
::InternetCloseHandle(_hRequest);
_hRequest=NULL;
__w3cexcept(_szaddress.c_str(), _nport, _t, szuri, "unknown exception...");
}