httpproxysocket.h

来自「HTTP是一个基于文本的协议」· C头文件 代码 · 共 86 行

H
86
字号
#if (!defined(__NEURO__PROXY__SOCKET__))
#define __NEURO__PROXY__SOCKET__



#include "SocketClient.h"



class CHttpProxySocketClient : public CSocketClient {
public:
	
	CString HttpServer;
	int		Port;

	virtual void AutoDetectProxy()
	{
		throw new CSocketException("Auto Detection Not Implemented Here. Please Contact Akash Kava at ackava@neurospeech.com","");
	}

	virtual void SetProxySettings(LPCTSTR lpszHttpServer,int nPort)
	{
		HttpServer = lpszHttpServer;
		Port = nPort;
	}

	virtual void ConnectTo(LPCTSTR lpszHost , int nPort)
	{

		// If No Http Proxy Server Specified then connect to host directly..
		if(HttpServer.IsEmpty())
		{
			CSocketClient::ConnectTo(lpszHost,nPort);
			return;
		}

		CSocketClient::ConnectTo(HttpServer,Port);
		
		CString Line;
		
		Line.Format("CONNECT %s:%d HTTP/1.0",lpszHost,nPort);
		(*this)<<Line;
		Line.Format("host: %s:%d",lpszHost,nPort);
		(*this)<<Line;
		Line.Empty();
		(*this)<<Line;

		
		
		(*this)>>Line;

		int i = Line.Find(' ');
		if(i!=-1)
			Line = Line.Mid(i+1);


		if(Line.Left(3)!="200")
		{


			// Sorry Guys Http Proxy Authentication Not Implemented !!!
			if(Line.Left(3)=="407")
			{
				AfxMessageBox("Sorry Guys Http Proxy Authentication Not Implemented in Demo!!!");
			}


			throw new CSocketException("Proxy Connection Denied",Line.Mid(4));
		}


		do
		{
			(*this)>>Line;
			if(Line.IsEmpty())
				break;
		}while(true);


	}

};


#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?