Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. HttpOpenRequest problem

HttpOpenRequest problem

Scheduled Pinned Locked Moved C / C++ / MFC
helphtmlsysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gecool
    wrote on last edited by
    #1

    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:->

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups