コード例 #1
0
ファイル: SyncEngineWrap.cpp プロジェクト: 3runo5ouza/rhodes
	char* fetch_remote_data(char* url)
		{
		char* cookie = 0;
		char* retval = 0;
		CHttpClient* gHttpClient = NULL;

		cookie = get_db_session(load_source_url());

		if (!cookie && !strstr(url, "clientcreate"))
			{
			return NULL;
			}

		gHttpClient = CHttpClient::NewL();

		gHttpClient->SetCookie(cookie);

		if (cookie)
			free(cookie);

		gHttpClient->InvokeHttpMethodL(CHttpConstants::EGet, (const TUint8*) url, strlen(url), NULL, 0, NULL);

		retval = gHttpClient->GetResponse();

		delete gHttpClient;
		
		return retval;
	}
コード例 #2
0
ファイル: HttpClient.cpp プロジェクト: jayliu/rhodes
CHttpClient* CHttpClient::NewLC()
{
    CHttpClient* self = new (ELeave)CHttpClient();
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}
コード例 #3
0
ファイル: SyncEngineWrap.cpp プロジェクト: 3runo5ouza/rhodes
	int push_remote_data(char* url, char* data, size_t data_size,char* contentType)
	{
		int retval = SYNC_PUSH_CHANGES_ERROR;
		char* szData = 0;
		char* cookie = 0;

		CHttpClient* gHttpClient = NULL;

		cookie = get_db_session(load_source_url());

		if (!cookie && !strstr(url, "clientcreate"))
			return SYNC_PUSH_CHANGES_ERROR;
		
		gHttpClient = CHttpClient::NewL();
		
		gHttpClient->SetCookie(cookie);
		
		gHttpClient->InvokeHttpMethodL(CHttpConstants::EPost,
				(const TUint8*) url, 
				strlen(url), 
				(const TUint8*) data,
				data_size, contentType);

		szData = gHttpClient->GetResponse();

		retval = szData ? SYNC_PUSH_CHANGES_OK : SYNC_PUSH_CHANGES_ERROR;

		if (szData)
			free(szData);

		delete gHttpClient;
		
		return retval;
	}
コード例 #4
0
ファイル: Benchmark.cpp プロジェクト: Caesar11/gStore
void* MyThread_run(void* thread_args)
{
	struct MyThread_args *args;
	args = (struct MyThread_args *)thread_args;
	CHttpClient hc;
	string res;
	int ret;
	ret = hc.Get("http://172.31.222.94:9000/?operation=query&username=root&password=123456&db_name=dbpedia&format=json&sparql="+args->sparql,res);
	int m = 0;
	for(int i = 0; i<args->sparql.length(); ++i)
	{
		if(args->sparql[i]=='?')
			++m;
		if(args->sparql[i]=='{')
			break;
	}
	int n = 0;
	for(int i = 0; i<res.length(); ++i)
	{
		if(res[i]=='{')
			++n;
	}
	int Num = (n-3)/(m+1);
	//if(Num<=10)
	//{
	//	ofstream f("result/"+int2string(args->num)+".txt");
	//	f<<res<<endl;
	//	f.close();
	//}	
	
	if(args->rnum != Num)
		correctness = false;
	pthread_exit(NULL);
}
コード例 #5
0
ファイル: Client.cpp プロジェクト: hlyces/teamtalk_TT
void CClient::connect()
{
    CHttpClient httpClient;
    string strUrl = m_strLoginDomain + "/msg_server";
    string strResp;
    CURLcode nRet = httpClient.Get(strUrl, strResp);
    if(nRet != CURLE_OK)
    {
        printf("login falied. access url:%s error\n", strUrl.c_str());
		g_configReturn = false;
        PROMPTION;
        return;
    }
    Json::Reader reader(Json::Features::strictMode());
    Json::Value value;
    if(!reader.parse(strResp, value))
    {
        printf("login falied. parse response error:%s\n", strResp.c_str());
		g_configReturn = false;
        PROMPTION;
        return;
    }
    string strPriorIp, strBackupIp;
    uint16_t nPort;
    try {
        uint32_t nRet = value["code"].asUInt();
        if(nRet != 0)
        {
            string strMsg = value["msg"].asString();
            printf("login falied. errorMsg:%s\n", strMsg.c_str());
			g_configReturn = false;
            PROMPTION;
            return;
        }
        strPriorIp = value["priorIP"].asString();
        strBackupIp = value["backupIP"].asString();
        nPort = string2int(value["port"].asString());
        
    } catch (std::runtime_error msg) {
        printf("login falied. get json error:%s\n", strResp.c_str());
		g_configReturn = false;
        PROMPTION;
        return;
    }

    g_pConn = new ClientConn(this);
    m_nHandle = g_pConn->connect(strBackupIp.c_str(), nPort, m_strName, m_strPass);
    if(m_nHandle != INVALID_SOCKET)
    {
        netlib_register_timer(CClient::TimerCallback, (void*)this, 1000);	
		g_configReturn = true;
    }
    else
    {
        printf("invalid socket handle\n");
    }
}
コード例 #6
0
ファイル: HttpClient.cpp プロジェクト: 5432935/Scut
void* ScutNetwork::CHttpClient::AsyncThreadProc( void * puCmd )
#endif
{	
	int nRet = -1;
	if (puCmd)
	{
		PAsyncInfo pAi = (PAsyncInfo)puCmd;
		if (!pAi->Sender) {
			return NULL;
		}
		CHttpClient* pSender = (CHttpClient*)pAi->Sender;
		if (!pSender)
		{
			return NULL;
		}
		pSender->m_bAsyncProcessing = true;
		pSender->m_bIsBusy = true;

		if (pAi->Mode == amGet)
		{
			nRet = pSender->HttpGet(pAi->Url, *(pAi->Response));
		}
		else
			nRet = pSender->HttpPost(pAi->Url, pAi->PostData, pAi->PostDataSize, *(pAi->Response), pAi->FormFlag);
		switch ((CURLcode)nRet)
		{
		case CURLE_OK:
			pAi->Status = aisSucceed;
			break;
		case CURLE_OPERATION_TIMEDOUT:
			pAi->Status = aisTimeOut;
			break;
		default:
			pAi->Status = aisFailed;
			break;
		}
		pSender->m_bAsyncProcessing = false;
		pSender->m_bIsBusy = false;

		//通知	
		if (pSender->isLuaHandleExist())
		{
			LuaHelper::Instance()->execFunc(pSender->m_strLuaHandle, (AsyncInfo*)pAi);
		}
		else
		{

			if (pSender->m_pNetNotify)
			{
				pSender->m_pNetNotify->OnNotify(pAi);
			}	
		}			
	}	
	return NULL;
}
コード例 #7
0
void CTimerOp_UrlClientRetry::TimerOp(WPARAM wParam, LPARAM /*lParam*/)
{
	CHttpClient	*pUrlClient = (CHttpClient*) wParam;

	if (NULL != pUrlClient && !IsBadWritePtr(pUrlClient, sizeof(CHttpClient)) )
	{
		if (thePrefs.GetVerbose())
			AddDebugLogLine(false, _T("Retry to connect <%s>"), pUrlClient->GetUserName());

		pUrlClient->TryToConnect(true);
	}
}
コード例 #8
0
/// 需要处理连接出错情况,对应的Peer可以隔一段时间再连接
void CHttpClientReqSocket::OnClose(int nErrorCode)
{
	if (client == NULL)
		return;
	
	CHttpClient* pHttpClient = STATIC_DOWNCAST(CHttpClient, client);

	if (nErrorCode == 0)
	{			
		pHttpClient->OnNoSizeFileComplete();	
	}

	CClientReqSocket::OnClose(nErrorCode);
}
コード例 #9
0
ファイル: test.cpp プロジェクト: szqh97/test
int main ( int argc, char *argv[] )
{
    
    curl_global_init(CURL_GLOBAL_ALL);
    CHttpClient client = CHttpClient();
    string strUrl = "http://192.168.1.249:80/TVAds/videocapture";
    //strUrl = "http://app-test.kaipao.cc/v1/user/loginv";

    string strInfo = "u=18814842159&p=111111&sign=42557FBC90E10CAD27FAC0F9D8BA94E9";
    string strResp;
    cout << "POST ret: " << client.Post(strUrl, strInfo, strResp) << endl;
    cout << strInfo << endl << strResp <<endl;
    curl_global_cleanup();



    return 0;
}			/* ----------  end of function main  ---------- */
コード例 #10
0
ファイル: http_client.cpp プロジェクト: CCChaos/RyzomCore
// ***************************************************************************
void CHttpPostTask::run(void)
{
	CHttpClient httpClient;
	std::string ret;

	if ( ! httpClient.connect(_Host))
	{
		return;
	}
	
	if ( ! httpClient.sendPost(_Host + _Page, _Params))
	{
		return;
	}
	
	httpClient.receive(ret);
	httpClient.disconnect();
}
コード例 #11
0
ファイル: SyncEngineWrap.cpp プロジェクト: 3runo5ouza/rhodes
	void makeLoginRequest(char* url, char* data)
	{
		char* session = NULL;
		CHttpClient* gHttpClient = CHttpClient::NewL();

		gHttpClient->InvokeHttpMethodL(CHttpConstants::EPost,
				(const TUint8*) url, 
				strlen(url), 
				(const TUint8*) data, 
				strlen(data), NULL);

		session = gHttpClient->GetCookie();

		if (session)
			set_db_session(load_source_url(), session);
		else
			delete_db_session(load_source_url());

		delete gHttpClient;
	}
コード例 #12
0
	//============================================================================================
	std::string sendMsg(const std::string &msg)
	{
		CHttpClient httpClient;
		std::string ret;
		if (!httpClient.connect("http://" + StartupHost))
		{
			throw NLMISC::Exception("Can't connect to http server");
		}
		//std::string postString = "http://" + StartupHost + StartupPage +  "?cmd=log&msg=" + msg;
		//nlwarning("POST STRING = %s", postString.c_str());
		if (!httpClient.sendPost("http://" + StartupHost + StartupPage, "cmd=log&msg=" + msg))
		{
			throw NLMISC::Exception("Post failed");
		}
		if (!httpClient.receive(ret))
		{
			throw NLMISC::Exception("Receive failed");
		}
		httpClient.disconnect();
		return ret;
	}
コード例 #13
0
ファイル: ExceptionSender.cpp プロジェクト: HamiguaLu/YaSync
void SendFile(TCHAR *szFilePath,TCHAR *szFileName)
{
	CHttpClient         objHttpReq ;
	CHttpResponse *     pobjHttpRes = NULL ;

	try {
		// Initialize the User Agent
		objHttpReq.SetInternet (_T ("YaSync CR")) ;

		// Add user's custom HTTP headers
		/*objHttpReq.AddHeader (_T ("Ryeol-Magic"), _T ("My Magic Header")) ;
		objHttpReq.AddHeader (_T ("User-Magic"), _T ("User's Magic Header")) ;*/

		// Add user's parameters
		objHttpReq.AddParam (_T ("FileName"), szFileName) ;
		
		// Specifies a file to upload
		objHttpReq.AddParam (szFileName,szFilePath, CHttpClient::ParamFile);

		// Start a new request
		objHttpReq.BeginUpload (_T ("http://a.mobitnt.com/cr.php")) ;

		// Specifies the number of bytes to send when the Proceed method is called.
		const DWORD     cbProceed = 1024 ;  // 1K

		do {
			int i = 0;

		} while ( !(pobjHttpRes = objHttpReq.Proceed (cbProceed)) ) ;

	} catch (httpclientexception e) {

	}
} 
コード例 #14
0
ファイル: ExceptionSender.cpp プロジェクト: HamiguaLu/YaSync
void SendSupportReq(TCHAR *szEmail,TCHAR *szProblem)
{
	CHttpClient         objHttpReq ;
	CHttpResponse *     pobjHttpRes = NULL ;

	try {
		// Initialize the User Agent
		objHttpReq.SetInternet (_T ("YaSync CR")) ;

		// Add user's custom HTTP headers
		/*objHttpReq.AddHeader (_T ("Ryeol-Magic"), _T ("My Magic Header")) ;
		objHttpReq.AddHeader (_T ("User-Magic"), _T ("User's Magic Header")) ;*/

		// Add user's parameters
		objHttpReq.AddParam (_T ("EMAIL"), szEmail);
		objHttpReq.AddParam (_T ("PROBLEM"), szProblem);
		

		// Start a new request
		objHttpReq.BeginPost (_T ("http://a.mobitnt.com/supportReq.php")) ;

		// Specifies the number of bytes to send when the Proceed method is called.
		const DWORD     cbProceed = 1024 ;  // 1K

		do {
			int i = 0;

		} while ( !(pobjHttpRes = objHttpReq.Proceed (cbProceed)) ) ;

	} catch (httpclientexception e) {

	}
}
コード例 #15
0
ファイル: snapiclient.cpp プロジェクト: dmdr/247001
//////////////////////////////////////////////////////////////
//	Send SMS alert
//////////////////////////////////////////////////////////////
bool CSNAPIClient::sms(CHARPTR host,USHORT port,CHARPTR sender,CHARPTR dialno,CHARPTR start)
{
	CMemplate memplate;
	CHttpClient client;
	StringObject result;
	httpResponseCode ret;

	//	Build URI
	CHAR uri[CBUFF_MEDIUM];
	sprintf(uri,"http://%s:%u/smsalert",host,port);
	result.Create();

	memplate.create(&babylon);
	memplate.createField(MTF_TEXT,"name","64,1,\"");
	memplate.createField(MTF_TEXT,"number","64,1,\"");

	SMetastruct *meta = memplate.metaAlloc("guests",10);
	int counter=2;

	//	Sneak in extra params
	meta->set(0,0,sender);
	meta->set(0,1,dialno);
	meta->set(1,0,start);
	meta->set(1,1,"");
		
	//	Build list
	onSMSRequest(*meta);

	//	Post request
	client.registerComs(this);
	ret = client.httpPost(uri,*meta,result);

	delete meta;
	result.Destroy();

	return ret == 200;
}
コード例 #16
0
void* notification_callback(void *parm) {
	notification_params_t* thread_params = (notification_params_t*) parm;
	
	if (thread_params) {
		// Create and install the active scheduler
	
		CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
		CleanupStack::PushL(activeScheduler);
		CActiveScheduler::Install(activeScheduler);

		CHttpClient* gHttpClient = CHttpClient::NewL();

		gHttpClient->InvokeHttpMethodL(CHttpConstants::EPost,
				(const TUint8*) thread_params->callback, strlen(
						thread_params->callback),
				(const TUint8*) thread_params->params, strlen(
						thread_params->params), NULL);

		delete gHttpClient;

		CleanupStack::PopAndDestroy(activeScheduler);
	}

	//clear parameters
	if (thread_params) {
		if (thread_params->callback)
			free( thread_params->callback );
		if (thread_params->params)
			free( thread_params->params );

		free(thread_params);
	}

	pthread_exit(NULL);
	return NULL;
}
コード例 #17
0
ファイル: example.cpp プロジェクト: Caesar11/gStore
// before you run this example, make sure that you have started up ghttp service (using bin/ghttp db_name port)
int main()
{

	CHttpClient hc;
	string res;
	int ret;

	//ret = hc.Get("http://172.31.222.94:9000/?operation=build&db_name=lubm&ds_path=data/LUBM_10.n3", res); 
	//cout<<res<<endl;
	
	//ret = hc.Get("http://172.31.222.94:9000/?operation=load&db_name=lubm", res); 
	//cout<<res<<endl;
	int result[6] = {10, 14, 14, 199424, 33910, 1039};
        string* sparql = new string[6];
        sparql[0] = "select ?v0 where\
                   {\
                   ?v0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/class/yago/LanguagesOfBotswana> .\
                   ?v0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>    <http://dbpedia.org/class/yago/LanguagesOfNamibia> .\
                   ?v0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Language> .\
                   }";
        sparql[1] = "select ?v0 where\
                   {\
                   ?v0 <http://dbpedia.org/ontology/associatedBand> <http://dbpedia.org/resource/LCD_Soundsystem> .\
                   }";
        sparql[2] = "select ?v2 where\
                   {\
                   <http://dbpedia.org/resource/!!Destroy-Oh-Boy!!> <http://dbpedia.org/property/title> ?v2 .\
                   }";
        sparql[3] = "select ?v0 ?v2 where\
                   {\
                   ?v0 <http://dbpedia.org/ontology/activeYearsStartYear> ?v2 .\
                   }";
        sparql[4] = "select ?v0 ?v1 ?v2 where\
                   {\
                   ?v0 <http://dbpedia.org/property/dateOfBirth> ?v2 .\
                   ?v1 <http://dbpedia.org/property/genre> ?v2 .\
                   }";
        sparql[5] = "select ?v0 ?v1 ?v2 ?v3 where\
                   {\
                   ?v0 <http://dbpedia.org/property/familycolor> ?v1 .\
                   ?v0 <http://dbpedia.org/property/glotto> ?v2 .\
                   ?v0 <http://dbpedia.org/property/lc> ?v3 .\
                   }";
	int tnum = 6;
	tnum = 3000;
	bool correctness = true;
	for(int i = 0; i < tnum; ++i)
	{
		ret = hc.Get("http://172.31.222.94:9000/?operation=query&format=json&sparql="+sparql[i%6],res);
		cout<< i <<endl;
                int m = 0;
		for(int ii = 0; ii<sparql[i%6].length(); ++ii)
		{
			if(sparql[i%6][ii] == '?')
				++m;
			if(sparql[i%6][ii] == '{')
				break;
		}
		int n = 0;
		for(int ii = 0; ii<res.length(); ++ii)	
		{
			if(res[ii] == '{')
				++n;
		}
		int Num = (n-3)/(m+1);
		if(Num!=result[i%6])
			correctness =false;
		
	}
	if (correctness == true)
		cout<< "The answers are correct!" <<endl;
	else
		cout<< "The answers exist errors!" <<endl;
	//ret = hc.Get("127.0.0.1:8080/query/data/ex0.sql", res); 
	//cout<<res<<endl;
	
	//ret = hc.Get("http://172.31.222.94:9000/?operation=monitor", res); 
	//cout<<res<<endl;
	
	//ret = hc.Get("http://172.31.222.94:9000/?operation=unload&db_name=lubm", res); 
	//cout<<res<<endl;

	return 0;
}
コード例 #18
0
ファイル: Controller.cpp プロジェクト: Hopedream/mm-win
bool CController::InitLogin(tstring& strPhone, tstring& strPwd)
{
	static int init_times(0);
	init_times++;

	//注册 todo
	if (NULL  != m_pLogin)
	{
		delete m_pLogin;
		m_pLogin = NULL;
	}

	//verify
	ostringstream osPost;
	osPost<<"cell_phone="
		<<strPhone.c_str()
		<<"&"
		<<"passwd="
		<<strPwd.c_str();

	tstring strUrl(WEB_SERVER_SITE_URL);
	strUrl += "verify";
	tstring strPost = osPost.str().c_str();
	tstring strResponse;

	CHttpClient reqClient;
	int nSucc = reqClient.Post(strUrl, strPost, strResponse);

	if (strResponse.empty())
	{
		//只有在第一次连接的时候才会弹出对话框,以后为自动重连,不能弹出对话框
		if (init_times <= 1)
		{
			CMsgBox* pMsgBox = new CMsgBox("错误",_T("连接服务器超时!"),MSGBOX_ICON_ERROR, MSGBOX_IDOK);
			pMsgBox->ShowModal(NULL);
		}		
		return false;
	}

	//if (nSucc == 1)	
	tstring strFind("access_token");
	int index = strResponse.find(strFind);
	if (index == -1)
	{
		//解析错误码:"code":"1001"=密码错误,"code":"1003"="用户不存在"
		tstring strErrorPwd("\"code\":\"1001\"");
		tstring strErrorNotExist("\"code\":\"1003\"");
		int nIndex1 = strResponse.find(strErrorPwd);
		int nIndex2 = strResponse.find(strErrorNotExist);

		if (nIndex1 != -1)
		{
			CMsgBox* pMsgBox = new CMsgBox("错误",_T("密码错误!"),MSGBOX_ICON_ERROR, MSGBOX_IDOK);
			pMsgBox->ShowModal(NULL);
		} 
		else if (nIndex2 != -1)
		{
			CMsgBox* pMsgBox = new CMsgBox("错误",_T("账户不存在!"),MSGBOX_ICON_ERROR, MSGBOX_IDOK);
			pMsgBox->ShowModal(NULL);
		}
		else
		{
			CMsgBox* pMsgBox = new CMsgBox("错误",_T("用户验证失败!"),MSGBOX_ICON_ERROR, MSGBOX_IDOK);
			pMsgBox->ShowModal(NULL);
		}

		return false;
	}
	index += strFind.length()+3;

	if (!strResponse.empty())
	{
		tstring strToken = strResponse.substr(index, 32/*strResponse.length()-index-2*/);

		//计算token长度
		if (!strToken.empty())
		{
			m_strToken = strToken;
			m_pLogin = new CLogin(strPhone, strPwd);
			if (NULL != m_pLogin)
			{
				return m_pLogin->LoginToServer();
			}
		}
	}

	return false;
}
コード例 #19
0
/****
*@author liangyong
*@param hWnd 父窗口线程
*@param msgName 消息名
*@param msgValue 消息值
*@param isDownload 上传/下载标识,TRUE为下载,FALSE为上传
******/
void StartSpeed(HWND hWnd,UINT msgName,int msgValue,bool isDownload)
{
	AllocConsole();
	CIniManager iniManager;
	CSocketMgr sock;
	CHttpClient httpClient;

	///获取账号信息以及测试服务器IP列表
	//ADSL_12.0_0.5_gzDSL38056189_26_广州市_218.19.41.92_183.63.146.250,218.15.238.166,59.39.183.126,61.145.85.202_183.63.146.250
	CString result_temp = httpClient.doGet(gl_ipQueue);
	CString result = _T("");
	//result.Format(_T("%s"),ipTmp);
	result = iniManager.GetAllTestIp(result_temp);
  	CT2A http_result_temp(result);
	std::string str(http_result_temp);
	std::string temp_str = "";
	temp_str = iniManager.getIpQueues(str);

	//测试服务器IP列表
	//183.63.146.250,218.15.238.166,59.39.183.126,61.145.85.202
	ipQueue = iniManager.split(temp_str);///测速IP列表
	//_cprintf("startSpeed::msgName = %d,startSpeed::msgValue = %d\r\n",msgName,msgValue);
	socks.clear();
	if(isDownload)//下载测速
	{
		for(int i=0;i<ipQueue.size();i++)
		{
			if(i<ipQueue.size())
			{
				const char* ip_temp;
				char* ip;
				ip_temp = ipQueue[i].c_str();
				ip = new char[strlen(ip_temp)+1];
				strcpy(ip,ip_temp);
				_cprintf("ip = %s\r\n",ip);
				sock.StartDownloadSpeedTest(hWnd,msgName,msgValue,ip);
				//_cprintf("msgName = %d,msgValue = %d\r\n",msgName,msgValue);
			}
			else
			{
				const char* ip_temp;
				char* ip;
				ip_temp = ipQueue[0].c_str();
				ip = new char[strlen(ip_temp)+1];
				strcpy(ip,ip_temp);
				_cprintf("ip = %s\r\n",ip);
				sock.StartDownloadSpeedTest(hWnd,msgName,msgValue,ip);
				//_cprintf("msgName = %d,msgValue = %d\r\n",msgName,msgValue);
			}
			
		}
		_cprintf("size is %d\r\n",handles.size());
	}
	else//上传测速
	{
		for(int i=0;i<ipQueue.size();i++)
		{
			if(i<ipQueue.size())
			{
				const char* ip_temp;
				char* ip;
				ip_temp = ipQueue[i].c_str();
				ip = new char[strlen(ip_temp)+1];
				strcpy(ip,ip_temp);
				sock.StartUploadSpeedTest(hWnd,msgName,msgValue,"192.168.1.118");
			}
			else
			{
				const char* ip_temp;
				char* ip;
				ip_temp = ipQueue[0].c_str();
				ip = new char[strlen(ip_temp)+1];
				strcpy(ip,ip_temp);
				sock.StartUploadSpeedTest(hWnd,msgName,msgValue,"192.168.1.118");
			}
			
		}
	}
}
コード例 #20
0
ファイル: HttpClient.cpp プロジェクト: 1514louluo/acl
void *CHttpClient::DoRequestThread(void* arg)
{
	CHttpClient *phClient = (CHttpClient*) arg;
	HTTP_HDR_REQ *hdr_req = NULL;
	HTTP_HDR_RES *hdr_res = NULL;
	HTTP_RES *http_res = NULL;
	ACL_VSTRING *buf = acl_vstring_alloc(256);
	ACL_VSTREAM *server = NULL;
	const char *pHost = NULL;
	ACL_VSTREAM *fp = NULL;
	int   ret;
	UINT  nForward = 0;
	time_t begin = 0;
	struct timeval begin_tv, end_tv;
	double time_cost = 0;

#undef RETURN
#define RETURN(_x_) do  \
{  \
	if (hdr_req)  \
		http_hdr_req_free(hdr_req);  \
	if (buf)  \
		acl_vstring_free(buf);  \
	if (hdr_res)  \
		http_hdr_res_free(hdr_res);  \
	if (http_res) {  \
		http_res->hdr_res = NULL;  \
		http_res_free(http_res);  \
	}  \
	if (server)  \
		acl_vstream_close(server);  \
	if (fp)  \
		acl_vstream_close(fp);  \
	gettimeofday(&end_tv, NULL); \
	time_cost = stamp_sub(&end_tv, &begin_tv); \
	if (time_cost >= 0) \
		phClient->ReportTime(time_cost); \
	phClient->ReportComplete(); \
	return (_x_);  \
} while(0)

	const char *pUrl = phClient->m_sReqUrl.GetString();
	hdr_req = http_hdr_req_create(pUrl, phClient->m_bPostMethod ? "POST" : "GET",
		phClient->m_bHttp11 ? "HTTP/1.1" : "HTTP/1.0");
	ASSERT(hdr_req);

	if (phClient->m_bZip)
		http_hdr_put_str(&hdr_req->hdr, "Accept-Encoding", "gzip, deflate");
	if (phClient->m_bKeepAlive)
		http_hdr_entry_replace(&hdr_req->hdr, "Connection", "Keep-Alive", 1);
	if (phClient->m_bPostMethod)
		http_hdr_put_int(&hdr_req->hdr, "Content-Length",
			(int) phClient->m_sHttpBody.GetLength());
	if (!phClient->m_sAccept.IsEmpty())
		http_hdr_put_str(&hdr_req->hdr, "Accept", phClient->m_sAccept.GetString());
	if (!phClient->m_sCtype.IsEmpty())
		http_hdr_put_str(&hdr_req->hdr, "Content-Type", phClient->m_sCtype.GetString());

	if (phClient->m_sHttpHdrAppend.GetLength() > 0) {
		ACL_ARGV *argv;
		HTTP_HDR_ENTRY *entry;
		int   i;
		
		argv = acl_argv_split(phClient->m_sHttpHdrAppend.GetString(), "\r\n");
		for (i = 0; i < argv->argc; i++) {
			entry = http_hdr_entry_new(argv->argv[i]);
			if (entry == NULL)
				continue;
			http_hdr_append_entry(&hdr_req->hdr, entry);
		}
		acl_argv_free(argv);
	}

FORWARD:

	http_hdr_build_request(hdr_req, buf);
	pHost = http_hdr_req_host(hdr_req);
	ASSERT(pHost);

	phClient->ReportReqHdr(acl_vstring_str(buf), (int) ACL_VSTRING_LEN(buf));

	CString serverAddr;

	if (phClient->m_bUseAddr)
		serverAddr.Format("%s", phClient->m_sServerAddr);
	if (serverAddr.GetLength() == 0)
		serverAddr.Format("%s", pHost);
	if (strchr(serverAddr.GetString(), ':') == NULL)
		serverAddr.AppendFormat(":80");

	time(&begin);
	gettimeofday(&begin_tv, NULL);
	server = acl_vstream_connect(serverAddr.GetString(),
				ACL_BLOCKING, 10, 10, 4096);
	if (server == NULL) {
		CString msg;

		msg.Format("Connect server(%s) error", serverAddr.GetString());
		phClient->ReportErrConnect(msg.GetString());
		RETURN (NULL);
	}

	if (phClient->m_bLocalSave && fp == NULL) {
		fp = acl_vstream_fopen(phClient->m_sLocalFile.GetString(),
			O_WRONLY | O_CREAT | O_TRUNC, 0600, 4096);
		if (fp == NULL) {
			acl_msg_error("%s(%d): can't create file(%s)",
				__FILE__, __LINE__, phClient->m_sLocalFile.GetString());
			RETURN (NULL);
		}
	}

	ret = acl_vstream_writen(server, acl_vstring_str(buf), ACL_VSTRING_LEN(buf));
	if (ret == ACL_VSTREAM_EOF) {
		acl_msg_error("%s(%d): write error", __FILE__, __LINE__);
		RETURN (NULL);
	}

	if (phClient->m_bPostMethod && !phClient->m_sHttpBody.IsEmpty())
	{
		if (acl_vstream_writen(server, phClient->m_sHttpBody.GetString(),
			phClient->m_sHttpBody.GetLength()) == ACL_VSTREAM_EOF)
		{
			acl_msg_error("%s(%d): write body error", __FILE__, __LINE__);
			RETURN (NULL);
		}
	}

	hdr_res = http_hdr_res_new();
	if (http_hdr_res_get_sync(hdr_res, server, 10) < 0) {
		acl_msg_error("%s(%d): get res hdr error", __FILE__, __FILE__, __LINE__);
		RETURN (NULL);
	}

	if (http_hdr_res_parse(hdr_res) < 0) {
		acl_msg_error("%s(%d): parse hdr_res error", __FILE__, __LINE__);
		RETURN (NULL);
	}

	http_hdr_build(&hdr_res->hdr, buf);
	phClient->ReportResHdr(acl_vstring_str(buf), (int) ACL_VSTRING_LEN(buf));
	phClient->ReportResContentLength((int) hdr_res->hdr.content_length);

	if (hdr_res->reply_status > 300	&& hdr_res->reply_status < 400) {
		const char* pLocation;
		HTTP_HDR_REQ *hdr_req_tmp;

		if (!phClient->m_bForwardAuto)
			RETURN (NULL);

		if (nForward++ >= phClient->m_nMaxTry) {
			acl_msg_error("%s(%d): too many redirect, nForward(%d)",
				__FILE__, __LINE__, nForward);
			RETURN (NULL);
		}

		pLocation = http_hdr_entry_value(&hdr_res->hdr, "Location");
		if (pLocation == NULL || *pLocation == 0) {
			acl_msg_error("%s(%d): 302 reply with no Location", __FILE__, __LINE__);
			RETURN (NULL);
		}

		hdr_req_tmp = http_hdr_req_rewrite(hdr_req, pLocation);
		if (hdr_req_tmp == NULL)
			RETURN (NULL);
		http_hdr_req_free(hdr_req);
		http_hdr_res_free(hdr_res);
		hdr_req = hdr_req_tmp;
		goto FORWARD;
	}

	http_res = http_res_new(hdr_res);
	while (1) {
		char  tmp_buf[4096];

		ret = (int) http_res_body_get_sync2(http_res, server,
				tmp_buf, sizeof(tmp_buf) - 1);
		if (ret <= 0)
			break;

		phClient->ReportResBody(tmp_buf, ret);
		phClient->ReportResDownLength((int)(time(NULL) - begin), ret);

		if (fp != NULL && acl_vstream_writen(fp, tmp_buf, ret) == ACL_VSTREAM_EOF) {
			acl_msg_error("%s(%d): write to file error", __FILE__, __LINE__);
			break;
		}
	}
	RETURN (NULL);
}