Ok I finally got it to work, after some pointers by n.m and some struggling here and there I finally got a working code:-
using namespace std;
#include "stdafx.h"
#include <stdio.h>
#include <curl.h>
#define YOUR_URL "http://invr28ppqa24:8080/examples"
#define ANYUSER ""
#define ANYPWD ""
int main(int argc, char* argv[])
{
//__asm int 3;
//initialize a curl object
CURLcode result;
int x;
CURL* curl = curl_easy_init(); //initialize a easy curl handle
if(curl){
curl_easy_setopt(curl,CURLOPT_USERNAME, ANYUSER); //set second option to enable anyuser, a trick necessary for program to work
curl_easy_setopt(curl,CURLOPT_USERNAME, ANYPWD);
curl_easy_setopt(curl,CURLOPT_VERBOSE, 1);
curl_easy_setopt(curl, CURLOPT_URL,YOUR_URL);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, "false");
curl_easy_setopt(curl, CURLOPT_USERAGENT, "curl/7.19.6 (i386-pc-win32) libcurl/7.19.6 OpenSSL/0.9.8k");
curl_easy_setopt(curl,CURLOPT_HTTPAUTH, CURLAUTH_GSSNEGOTIATE); //set first option to enable gssnegotiate authentication
curl_easy_perform(curl);
//curl_easy_cleanup(curl);
scanf("%d", &x); //last statement used to get delay in demo situations
}
return 0;
}
The 302 still comes and I have to manually set the useragent (not so elegant). Because of follow location, the problem was primarily solved. Thanks.
The initial 302 error is still there and left unanswered.