CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006
    Posts
    12

    WININET Help -- HttpOpenRequest()

    Hello,

    Hopefully one of you here can help me with this problem I am having. Basically I'm trying to do an https post to a website to retrieve just simple text data and I think my problem is coming from HttpOpenRequest() because it is returning the errorcode 1359 in GetLastError(). I have already written this application once in Windows XP ( works perfectly using winhttp ) but I can't get it to work with Windows CE ( using WinInet ). I'll be brief and post more info if it is needed. Anyways, I need help porting... I'll just go through the lines of my major function calls and show you where it takes a poop. ( I'm only posting the function calls in question just in case you guys catch anything )


    WinInet Version:

    Code:
    // Use InternetOpen to obtain a session handle.
    	httpdata->hSession =   InternetOpen(L"XXX",INTERNET_OPEN_TYPE_PRECONFIG,  							       NULL, NULL, 0 );
    
    if ( httpdata->hSession )
    		httpdata->hConnect = 
    InternetConnect( httpdata->hSession,  hostname, INTERNET_DEFAULT_HTTPS_PORT,					
    				                          NULL, 
    	                                                  NULL,											                                  INTERNET_SERVICE_HTTP, 
    							  0, 
    						          0 );
    
    if ( httpdata->hConnect )
    		httpdata->hRequest = HttpOpenRequest( httpdata->hConnect,
    		                                                                          L"POST", 
    											  pathname,
    											  NULL,
    											  NULL,
    											  NULL,
    											  0,
    									   INTERNET_FLAG_SECURE);
    
    	if ( !httpdata->hRequest )
    		iError = (int)GetLastError(); 
    
         // ERROR = ERROR_INTERNAL_ERROR
    Basically, if I remove the INTERNET_FLAG_SECURE I won't get any errors but I obviously won't be getting any data in my databuffer later when I do HttpSendRequest, InternetQueryDataAvailable, and InternetReadFile since I need it to do HTTPS.

    My WinHttp Version is this:
    Code:
    httpdata->hRequest = WinHttpOpenRequest( httpdata->hConnect, 
    									   method, 
    									   pathname,
    									   NULL, 
    									   WINHTTP_NO_REFERER, 							                        WINHTTP_DEFAULT_ACCEPT_TYPES,
    									   WINHTTP_FLAG_SECURE );
    and this works fine. Why won't be CE version work with the INTERNET_FLAG_SECURE flag?

  2. #2
    Join Date
    Dec 2006
    Posts
    12

    Re: WININET Help -- HttpOpenRequest()

    Man...no responses. Did I post enough information or does the above look correct to you guys? I'm thinking I may be missing a flag I need in HttpOpenRequest? My other version works fine...

  3. #3
    Join Date
    Nov 2008
    Location
    Bangalore
    Posts
    12

    Re: WININET Help -- HttpOpenRequest()

    Hi,

    In httpdata->hRequest = HttpOpenRequest( httpdata->hConnect, L"POST", pathname, NULL, NULL, NULL, 0, INTERNET_FLAG_SECURE);
    what pathname you are sending.
    I think " we need to indicate the page to which the data will be posted". Please check it. I m also checking the flags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured