CInternetSession::OpenURL exception if headers are defined. Works fine if not. Why?

Posted by Jesse on Stack Overflow See other posts from Stack Overflow or by Jesse
Published on 2010-05-04T08:03:45Z Indexed on 2010/05/04 8:08 UTC
Read the original article Hit count: 252

Filed under:
|
|

Trying to log the application version details in our weblogs using the headers:

Should be a one liner..but for some reason whenever I specify anything but NULL for the headers it causes an exception (InternetOpenUrl() call returns NULL) - anyone able to explain why?

  CInternetSession internet;
  CHttpFile * pHttpFile;
  CString headers;// = APPLICATION_SUITE_NAME;
  DWORD dwHeadersLength = -1;

  headers.Format("%s %s %s\n",APPLICATION_SUITE_NAME,SHORT_APPLICATION_VERSION,BUILDNO_STR);

  pHttpFile =(CHttpFile *) internet.OpenURL(lpszURL, 1, INTERNET_FLAG_TRANSFER_ASCII|INTERNET_FLAG_DONT_CACHE, headers, dwHeadersLength);

Without the headers, dwHeadersLength parameter (eg. pass in NULL,-1) then it goes through fine and I see the request come through to our website. But why does it fail if I pass in custom headers?

© Stack Overflow or respective owner

Related posts about visual-c++

Related posts about mfc