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. ERROR_INSUFFICIENT_BUFFER when calling HttpOpenRequest on separate thread

ERROR_INSUFFICIENT_BUFFER when calling HttpOpenRequest on separate thread

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
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.
  • T Offline
    T Offline
    tuxyboy
    wrote on last edited by
    #1

    This code works perfect without exceptions when calling it from the main appthread, but when called on a working thread (AfxBeginThread) httpOpenRequest gives a valid handle and the function works but a bunch of exception occures during the call and afterwards GetLastError returns ERROR_INSUFFICIENT_BUFFER. I know I shouldn't be worried if I get a valid handle but anyway.... Any ideas? code: CONST TCHAR *szAcceptType = TEXT(HTTP_ACCEPT_TYPE); HINTERNET hHTTPRequest = NULL; CHECK_BOOL(NULL != (hHTTPRequest=::httpOpenRequest(hSession, // HTTP session handle HTTP_VERB_HEAD, // HTTP Verb szURI, // Object Name HTTP_VERSION, // Version NULL, // Reference &szAcceptType, // Accept Type INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION, NULL))); // context call-back point CHECK_BOOL(hHTTPRequest != INVALID_HANDLE_VALUE); // REPLACE HEADER CHECK_BOOL(::HttpAddRequestHeaders( hHTTPRequest, HTTP_ACCEPT, _tcslen(HTTP_ACCEPT), HTTP_ADDREQ_FLAG_REPLACE)); // SEND REQUEST CHECK_BOOL(::HttpSendRequest( hHTTPRequest, // 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 return hHTTPRequest; CLEANUP: m_dwError=::GetLastError(); #ifdef _DEBUG LPVOID lpMsgBuffer; DWORD dwRet=FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, GetModuleHandle("wininet.dll"), m_dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&lpMsgBuffer), 0, NULL); // Display the string. MessageBox( NULL, (LPCTSTR)lpMsgBuffer, "Error", MB_OK | MB_ICONINFORMATION ); LocalFree(lpMsgBuffer); #endif if (hHTTPRequest) InternetCloseHandle(hHTTPRequest); hHTTPRequest = NULL; return hHTTPRequest;

    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