MFC-OCX and CInternetSession->CHttpConnection->CHttpFile? 
Author Message
 MFC-OCX and CInternetSession->CHttpConnection->CHttpFile?

I had a DLL that implemented the task of sending an HttpRequest to a
server, transferring some data within it's headers, receive the
returned document and shut down the connection. It all worked fine.
But I had to convert it to an ActiveX-Control (OCX).
I created the OCX and copied the code responsible for connection,
transfer and disconnection to the new method within the OCX. Now I
tried to test it from VB, but I only get error 405 (Server does not
support requested method)... what am I doing wrong? Why is exactly the
same code working differently under different circumstances (in a DLL
/ in an OCX)?

Here's my code:

// m_szRemoteHost
// m_szRemotePort
// m_szRemoteDocument
// m_szUserName
// m_szPassword
// contain the obvious (they're all CString class members)

     CInternetSession internetSession("My Http Control",
                                                    0,

INTERNET_OPEN_TYPE_PRECONFIG,
                                                    NULL,
                                                    NULL,

INTERNET_FLAG_RELOAD |

INTERNET_FLAG_DONT_CACHE |

INTERNET_FLAG_NO_AUTO_REDIRECT);
     CHttpConnection* httpConnection;
     CHttpFile* httpFile;
     BOOL sendRequestErg = FALSE;
     BOOL queryInfoStatusCodeErg = FALSE;
     DWORD serverErg = 0;

     httpConnection =
internetSession.GetHttpConnection(m_szRemoteHost,

(INTERNET_PORT)m_sRemotePort,
                                                    m_szUserName,
                                                    m_szPassword);
     httpFile = httpConnection->OpenRequest(0,

m_szRemoteDocument,
                                                    NULL,
                                                    0,
                                                    NULL,
                                                    NULL,

INTERNET_FLAG_RELOAD |

INTERNET_FLAG_DONT_CACHE |

INTERNET_FLAG_NO_AUTO_REDIRECT);

      CString postHeader("CUSTOMHEADER:myHeaderData");
      postHeader += (char)13;
      postHeader += (char)10;
      addRequestHeadersErg = httpFile->AddRequestHeaders(postHeader,

postHeader.GetLength());
      if (!addRequestHeadersErg)
      {
       internetSession.Close();
       return SetLastError(-31, IDS_ADD_HEADER_ERROR);
      }
     }

     sendRequestErg = httpFile->SendRequest(NULL, 0, NULL, 0);
     if (!sendRequestErg)
     {
      internetSession.Close();
      return SetLastError(-32, IDS_SEND_REQUEST_ERROR);
     }

     // CHttpFile Errors
     queryInfoStatusCodeErg =
httpFile->QueryInfoStatusCode(serverErg);
     if (!queryInfoStatusCodeErg)
     {
      httpFile->Close();
      internetSession.Close();
      return SetLastError(-33, IDS_REQUEST_STATUS_ERROR);
     }

well, and here, serverErg contains 405 (the error code mentioned
above)
What am I doing wrong? And what makes it accidentially work as a DLL,
but not as an OCX?

Any help/hint will be highly appreciated.
best wishes,
thomas

----------------------------------------------------------------------
my eMail address has been modified - it must not be used for
commercial purposes!
I think you can guess what should be removed in order to get back to
me...



Sun, 01 Apr 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. MFC-OCX and CInternetSession->CHttpConnection->CHttpFile?

2. B>C>C++>VC++(MFC)>RAW API PROGRAMMING>ATL>COM>OLE>ADO>ASP.............

3. >>>>>>>>> What would you like in a debugger?

4. <<<<<<<Parsing help, please>>>>>>>>

5. C->->->->C++

6. >>>> PUBLICATION QUALITY SOFTWARE MANUAL

7. File Format conversion, ascii freeform -->.csv <-->.wk1<-->dbf<-->?HELP

8. <<<>>>Need C code advice with functions and sorting.<<<>>>

9. >>>>>>Not enough C/UNIX people in NYC!

10. <><><>HELP<><><> PCMCIA Motorola Montana 33.6

11. >>---> Software Jobs! >>--->

12. mfc and >> operator

 

 
Powered by phpBB® Forum Software