我用WinInet方式Get/post 某些網站,有的沒問題,而有的就有問題,這是我構造的協議頭。我這是根據別人的e語言代碼翻譯過來的,用人家的e代碼完全沒問題,可是我翻譯過來就出問題了,呼叫HttpSendRequest 回傳FALSE,錯誤嗎是12150。百度了很多資料,試了各種方法,一直解決不了,求大神指導。我是UNICODE程式
//CString strSubjoinProtocolHeader;
if (strSubjoinProtocolHeader.Find(L"Accept: ") == -1)
strSubjoinProtocolHeader = strSubjoinProtocolHeader + L"Accept: text/html, application/xhtml+xml, */*\r\n";
if (strSubjoinProtocolHeader.Find(L"Accept-Encoding: ") == -1)
strSubjoinProtocolHeader = strSubjoinProtocolHeader + L"Accept-Encoding: gbk, GB2312\r\n";
if (strSubjoinProtocolHeader.Find(L"Referer: ") == -1)
strSubjoinProtocolHeader = strSubjoinProtocolHeader + L"Referer: " + strUrl+L"\r\n";
if (strSubjoinProtocolHeader.Find(L"Accept-Language: ") == -1)
strSubjoinProtocolHeader = strSubjoinProtocolHeader + L"Accept-Language: zh-cn\r\n";
if (strSubjoinProtocolHeader.Find(L"Content-Type: ") == -1)
strSubjoinProtocolHeader = strSubjoinProtocolHeader + L"Content-Type: application/x-www-form-urlencoded\r\n";
if (strSubjoinProtocolHeader.Find(L"Cache-Control: ") == -1)
strSubjoinProtocolHeader = strSubjoinProtocolHeader + L"Cache-Control: no-cache\r\n";
if (strSubmitCookies.IsEmpty() == FALSE)
strSubjoinProtocolHeader = strSubjoinProtocolHeader + L"Cookie: " + strSubmitCookies+L"\r\n";
CString strTempVisitType = strVisitType;
strTempVisitType.MakeLower();
if (strTempVisitType == L"get")
bFlag = HttpSendRequest(hHttpRequest, strSubjoinProtocolHeader, strSubjoinProtocolHeader.GetLength(), NULL, 0);
int nError = GetLastError();
if (bFlag == FALSE)
uj5u.com熱心網友回復:
12150 ERROR_HTTP_HEADER_NOT_FOUNDThe requested header could not be located.
uj5u.com熱心網友回復:
直接抓去一下你發送的包的http header資訊,看是否正確uj5u.com熱心網友回復:
注意 MSDN 上的 NoteNote The HttpSendRequestA function represents headers as ISO-8859-1 characters not ANSI characters. The HttpSendRequestW function represents headers as ISO-8859-1 characters converted to UTF-16LE characters. As a result, it is never safe to use the HttpSendRequestW function when the headers to be added can contain non-ASCII characters. Instead, an application can use the MultiByteToWideChar and WideCharToMultiByte functions with a Codepage parameter set to 28591 to map between ANSI characters and UTF-16LE characters.
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/136525.html
標籤:網絡編程
上一篇:有關MFC中combobox問題
