Click here to Skip to main content
15,944,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
NewsRe: Interface not registered Pin
CodingLover22-Oct-08 0:21
CodingLover22-Oct-08 0:21 
AnswerRe: Interface not registered Pin
Roger Stoltz22-Oct-08 0:26
Roger Stoltz22-Oct-08 0:26 
Questioncustom service and application - resource lock ? Pin
dharani20-Oct-08 23:34
dharani20-Oct-08 23:34 
AnswerRe: custom service and application - resource lock ? Pin
dehseth21-Oct-08 0:26
dehseth21-Oct-08 0:26 
QuestionSearching for a Manifest File Pin
si_6920-Oct-08 23:15
si_6920-Oct-08 23:15 
AnswerRe: Searching for a Manifest File Pin
_AnsHUMAN_ 20-Oct-08 23:25
_AnsHUMAN_ 20-Oct-08 23:25 
GeneralRe: Searching for a Manifest File Pin
si_6920-Oct-08 23:51
si_6920-Oct-08 23:51 
QuestionAssertion fail error when loading a DLL? Pin
bankey101020-Oct-08 23:10
bankey101020-Oct-08 23:10 
AnswerRe: Assertion fail error when loading a DLL? Pin
Roger Stoltz20-Oct-08 23:22
Roger Stoltz20-Oct-08 23:22 
AnswerRe: Assertion fail error when loading a DLL? Pin
CPallini20-Oct-08 23:25
mveCPallini20-Oct-08 23:25 
QuestionPrinting data to a pdf document using win32 sdk c++ Pin
raesa20-Oct-08 22:53
raesa20-Oct-08 22:53 
AnswerRe: Printing data to a pdf document using win32 sdk c++ Pin
Rajesh R Subramanian20-Oct-08 22:57
professionalRajesh R Subramanian20-Oct-08 22:57 
GeneralRe: Printing data to a pdf document using win32 sdk c++ Pin
raesa21-Oct-08 0:13
raesa21-Oct-08 0:13 
QuestionMS FLex Grid Usage In MS VS 2005 Pin
dehseth20-Oct-08 22:39
dehseth20-Oct-08 22:39 
AnswerRe: MS FLex Grid Usage In MS VS 2005 Pin
dehseth21-Oct-08 0:57
dehseth21-Oct-08 0:57 
QuestionUpload a file in mfc through HTTP and not FTP Pin
Dhiraj kumar Saini20-Oct-08 22:35
Dhiraj kumar Saini20-Oct-08 22:35 
AnswerRe: Upload a file in mfc Pin
dehseth20-Oct-08 22:45
dehseth20-Oct-08 22:45 
GeneralRe: Upload a file in mfc Pin
Dhiraj kumar Saini20-Oct-08 22:56
Dhiraj kumar Saini20-Oct-08 22:56 
GeneralRe: Upload a file in mfc Pin
Prasann Mayekar20-Oct-08 23:45
Prasann Mayekar20-Oct-08 23:45 
GeneralRe: Upload a file in mfc Pin
Dhiraj kumar Saini20-Oct-08 23:52
Dhiraj kumar Saini20-Oct-08 23:52 
GeneralRe: Upload a file in mfc Pin
Prasann Mayekar21-Oct-08 0:52
Prasann Mayekar21-Oct-08 0:52 
GeneralRe: Upload a file in mfc Pin
Dhiraj kumar Saini21-Oct-08 2:54
Dhiraj kumar Saini21-Oct-08 2:54 
Questionwinhttp issue Pin
George_George20-Oct-08 22:23
George_George20-Oct-08 22:23 
Hello everyone,


Here is my code. My code is a client application which uses WinHttp to access http://connect.microsoft.com/dashboard, I tested with IE only if valid .Net Passport account is provided, the authentication could pass, or else can not access the service.

But I tested my below code, no matter I provide valie or invalid .Net Passport account, each time 200 OK is returned. Anyone has ideas why it always returns 200 OK?

#include <windows.h>
#include <Winhttp.h>
#include <stdio.h>

#pragma comment(lib,"Winhttp.lib")

void WinHttpAuthSample()
{
  DWORD dwStatusCode = 0;
  DWORD dwLastStatus = 0;
  DWORD dwSize = sizeof(DWORD);
  BOOL  bResults = FALSE;
  BOOL  bDone = FALSE;

  DWORD dwProxyAuthScheme = 0;
  HINTERNET  hSession = NULL, 
             hConnect = NULL,
             hRequest = NULL;

  hSession = WinHttpOpen( L"WinHTTP Example/1.0",  
                          WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
                          WINHTTP_NO_PROXY_NAME, 
                          WINHTTP_NO_PROXY_BYPASS, 0 );

  INTERNET_PORT nPort = INTERNET_DEFAULT_HTTPS_PORT;

  if( hSession )
    hConnect = WinHttpConnect( hSession, 
                               L"connect.microsoft.com", 
                               nPort, 0 );

  if( hConnect )
    hRequest = WinHttpOpenRequest( hConnect, 
                                   L"GET", 
                                   L"/dashboard",
                                   NULL, 
                                   WINHTTP_NO_REFERER, 
                                   WINHTTP_DEFAULT_ACCEPT_TYPES,
                                   WINHTTP_FLAG_SECURE);
  if( hRequest == NULL )
    bDone = TRUE;

  while( !bDone )
  {
    if( dwProxyAuthScheme != 0 )
      bResults = WinHttpSetCredentials( hRequest, 
                                        WINHTTP_AUTH_TARGET_PROXY, 
                                        dwProxyAuthScheme, 
                                        L"username@hotmail.com",
                                        L"passport password",
                                        NULL );
    bResults = WinHttpSendRequest( hRequest,
                                   WINHTTP_NO_ADDITIONAL_HEADERS,
                                   0,
                                   WINHTTP_NO_REQUEST_DATA,
                                   0, 
                                   0, 
                                   0 );

    if( bResults )
      bResults = WinHttpReceiveResponse( hRequest, NULL );

    if( !bResults && GetLastError( ) == ERROR_WINHTTP_RESEND_REQUEST)
        continue;

    if( bResults ) 
      bResults = WinHttpQueryHeaders( hRequest, 
                                      WINHTTP_QUERY_STATUS_CODE |
                                      WINHTTP_QUERY_FLAG_NUMBER,
                                      NULL, 
                                      &dwStatusCode, 
                                      &dwSize, 
                                      NULL );

    if( bResults )
    {
      switch( dwStatusCode )
      {
        case 200: 

		 printf( "The resource was successfully retrieved.\n" );
         bDone = TRUE;
         break;

        case 401:
         
          printf(" The server requires authentication. Sending credentials...\n" );

          bDone = TRUE;

          break;

        case 407:
         
          printf( "The proxy requires authentication.  Sending credentials...\n" );

          bDone = TRUE;
          break;

        default:
         
          printf("Error. Status code %d returned.\n", dwStatusCode);
          bDone = TRUE;
      }
    }

    dwLastStatus = dwStatusCode;

    if( !bResults ) 
        bDone = TRUE;
  }

  if( !bResults )
  {
    DWORD dwLastError = GetLastError( );
    printf( "Error %d has occurred.\n", dwLastError );
  }

  // Close any open handles.
  if( hRequest ) WinHttpCloseHandle( hRequest );
  if( hConnect ) WinHttpCloseHandle( hConnect );
  if( hSession ) WinHttpCloseHandle( hSession );
}

int main(int argc, char* argv[])
{
         WinHttpAuthSample();
         return 0;
}



thanks in advance,
George
Questionregards MicroSoft visual C++ certification Pin
raju000320-Oct-08 22:03
raju000320-Oct-08 22:03 
AnswerRe: regards MicroSoft visual C++ certification Pin
Rajesh R Subramanian20-Oct-08 22:06
professionalRajesh R Subramanian20-Oct-08 22:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.