Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Type Promotion in C Pin
Adam Roderick J21-Oct-09 21:57
Adam Roderick J21-Oct-09 21:57 
QuestionHttp Response Code is -1 ? Pin
VishalIndia21-Oct-09 20:29
VishalIndia21-Oct-09 20:29 
AnswerRe: Http Response Code is -1 ? Pin
Randor 21-Oct-09 21:22
professional Randor 21-Oct-09 21:22 
GeneralRe: Http Response Code is -1 ? Pin
VishalIndia21-Oct-09 22:05
VishalIndia21-Oct-09 22:05 
GeneralRe: Http Response Code is -1 ? Pin
Randor 22-Oct-09 16:40
professional Randor 22-Oct-09 16:40 
GeneralRe: Http Response Code is -1 ? Pin
VishalIndia24-Oct-09 7:01
VishalIndia24-Oct-09 7:01 
GeneralRe: Http Response Code is -1 ? Pin
Randor 24-Oct-09 16:55
professional Randor 24-Oct-09 16:55 
GeneralRe: Http Response Code is -1 ? Pin
rahul.kulshreshtha29-Oct-09 0:12
rahul.kulshreshtha29-Oct-09 0:12 
Hi Randor,
I am getting http response code = 407 while using proxy. I know it is for proxy authentication. I wrote the following code. Can you tell me where is my mistake.

        std::string responseData("");

	DWORD statusCode;
	CInternetSession iSession = CInternetSession(L"My Application",1,INTERNET_OPEN_TYPE_PROXY, L"http://proxy.mycompany.com:8080");
	CHttpConnection *httpConnection = NULL;
	CHttpFile *httpFile = NULL;
	char userName[] = "myUsername", password[] = "myPassword";

	try
	{
		iSession.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, (int)1000000000);
		iSession.SetOption(INTERNET_OPTION_CONTROL_SEND_TIMEOUT, (int)1000000000);
		iSession.SetOption(INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, (int)1000000000);
		iSession.SetOption(INTERNET_OPTION_DATA_SEND_TIMEOUT, (int)1000000000);
		iSession.SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT, (int)1000000000);
		iSession.SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT, (int)1000000000);
		iSession.SetOption(INTERNET_OPTION_SEND_TIMEOUT, (int)1000000000);
		iSession.SetOption(INTERNET_OPTION_PROXY_USERNAME, userName, strlen(userName) + 1);
		iSession.SetOption(INTERNET_OPTION_PROXY_PASSWORD, password, strlen(password) + 1);

		httpConnection = iSession.GetHttpConnection(CString("subdomain.maindomain.com"), (INTERNET_PORT) 443);
		httpFile = httpConnection->OpenRequest(L"POST", CString("/somepage/"), 0, 1, 0, 0, INTERNET_FLAG_SECURE); 
		httpConnection->SetOption(INTERNET_OPTION_CONNECT_TIMEOUT, (int)1000000000);
		CString strHeader;
		int contentLength =0;// (int)strContent.length();
		strHeader = "Content-Type: application/x-amf";
		httpFile->AddRequestHeaders(strHeader);
		strHeader.Format(L"Content-Length: %d", contentLength);
		httpFile->AddRequestHeaders(strHeader);

		BOOL x = httpFile->SendRequest(NULL, 0, NULL, contentLength);

		httpFile->QueryInfoStatusCode(statusCode);
		if(statusCode != 200)
		{
			responseData = "";
			//return;
		}
		char fileData[1024];
		int len;
		while((len = httpFile->Read(fileData, 1024)) > 0)
			responseData.append(fileData, len);
//		logManager.Print(LL_INTINFO, PRINT_LOG("Send Request Success"));
	}
	//catch(CInternetException *ex)
	catch(CException *ex)
	{
		
		WCHAR str[500];
		DWORD errorCode = GetLastError();
		ex->GetErrorMessage(str, GetLastError());
		//AfxMessageBox(L"HTTPException Comming");
		//AfxMessageBox(str);
		//cStringToChar(str, lastException);
		//logManager.Print(LL_INTERR, PRINT_LOG("HTTP Exception %s"), lastException.c_str());

	}



I am using AMF so I specified 443 port while my proxy is using 8080 port.
QuestionHow to catch exception before a crash happens? Pin
jtasph21-Oct-09 20:20
jtasph21-Oct-09 20:20 
AnswerRe: How to catch exception before a crash happens? Pin
Randor 21-Oct-09 20:29
professional Randor 21-Oct-09 20:29 
QuestionRe: How to catch exception before a crash happens? Pin
jtasph21-Oct-09 20:39
jtasph21-Oct-09 20:39 
AnswerRe: How to catch exception before a crash happens? Pin
Randor 21-Oct-09 20:57
professional Randor 21-Oct-09 20:57 
GeneralOT Pin
Rajesh R Subramanian21-Oct-09 20:59
professionalRajesh R Subramanian21-Oct-09 20:59 
GeneralRe: OT Pin
Randor 21-Oct-09 21:06
professional Randor 21-Oct-09 21:06 
GeneralRe: OT-2 Pin
CPallini21-Oct-09 21:10
mveCPallini21-Oct-09 21:10 
JokeRe: OT-2 Pin
Rajesh R Subramanian22-Oct-09 7:39
professionalRajesh R Subramanian22-Oct-09 7:39 
GeneralRe: OT-2 Pin
CPallini22-Oct-09 9:26
mveCPallini22-Oct-09 9:26 
AnswerRe: How to catch exception before a crash happens? Pin
Naveen21-Oct-09 20:59
Naveen21-Oct-09 20:59 
QuestionRe: How to catch exception before a crash happens? Pin
jtasph21-Oct-09 21:26
jtasph21-Oct-09 21:26 
AnswerRe: How to catch exception before a crash happens? Pin
Naveen21-Oct-09 21:53
Naveen21-Oct-09 21:53 
AnswerRe: How to catch exception before a crash happens? Pin
Randor 21-Oct-09 22:10
professional Randor 21-Oct-09 22:10 
GeneralRe: How to catch exception before a crash happens? Pin
jtasph21-Oct-09 22:18
jtasph21-Oct-09 22:18 
QuestionRe: How to catch exception before a crash happens? [modified] Pin
jtasph21-Oct-09 23:16
jtasph21-Oct-09 23:16 
QuestionNeed help for CStdioFile Read mode Pin
Nicholas Amh21-Oct-09 19:23
Nicholas Amh21-Oct-09 19:23 
AnswerRe: Need help for CStdioFile Read mode Pin
Adam Roderick J21-Oct-09 19:38
Adam Roderick J21-Oct-09 19:38 

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.