HttpOpenRequest problem
-
Hi everyone. I need some help on this: I am using wininet funcs to "talk" to a http server. I am opening a root handle with InternetOpen (ret code OK), than I call Internetconnect (ret code OK). I am openning then a request handle, with HttpOpenRequest:
void CfileURL::OpenRequest() { LPCTSTR lpszVerb = "GET"; LPCTSTR lpszObjectName = "/avcenter/venc/data/w32.kelvir.c.html"; LPCTSTR lpszVersion = NULL; // Use default. LPCTSTR lpszReferrer = NULL; // No referrer. LPCTSTR lplpszAcceptTypes =("Accept : */* ""Accept-Ranges: bytes"); DWORD dwOpenRequestFlags = INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS | INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_AUTH | INTERNET_FLAG_NO_AUTO_REDIRECT | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI | INTERNET_FLAG_RELOAD; DWORD dwOpenRequestContext = 0; m_h_Request = HttpOpenRequest(m_h_URL, lpszVerb, m_URL.object_name, lpszVersion, lpszReferrer, (LPCTSTR *) &lplpszAcceptTypes, dwOpenRequestFlags, dwOpenRequestContext); // if (!m_h_Request) DWORD err=GetLastError(); //*************End HttpOpenRequest**************** return err; }
then i make char ah[] = "Range: bytes=0-30"; bool bResult = HttpAddRequestHeaders(m_h_Request, ah, strlen(ah), HTTP_ADDREQ_FLAG_ADD_IF_NEW); and then i send the request with HttpSendRequest, to determine if the server accepts bytes range. I get the status code 206 (partial content) (for the server I use) which is ok for me. I close the m_h_Request handle obtain from the previous call to httpopenhandle. Then I make a new request, to determine the file size: bool bret = OpenRequest(); bool bResult = HttpSendRequest(m_h_Request, NULL, 0, NULL, 0); DWORD dwSize = sizeof(DWORD); DWORD infolevel = HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER; if (!HttpQueryInfo(m_h_Request, infolevel, &m_dwflen, &dwSize, NULL)) DWORD qi = GetLastError(); then i close the handle m_h_Request (httpopenrequest) at this point i have determined the file size, which is ok, BUT when i try to open a new request with the above function i get ret code 122 which is ERROR_INSUFFICIENT_BUFFER. What i do not understand is why at first two calls OpenRequest returned ok, and now it returns 122. If anyone can tell me which is the right way to use the httpOpenrequest, handle (should i or i should not close the handle after each request, than open it again for a new request) please do so. Any help is wellcome. THANKZ:->