InternetCrackUrl

 

 

InternetCrackUrl函数是把一个URL填充到URL_COMPONENTS结构中,

那返回的是0,是什么意思了?能指点一下吗?
 
 
InternetCrackUrl函数是把一个URL填充到URL_COMPONENTS结构中。

不是下载用的。
Response MESInterface::Send(const string & info, const string & apiPath, string m_username, string m_password) { // 检查连接状态 if (m_connectionState != ConnectionState::Connected) { CreateSocket(); // 尝试重连 // 重连后仍然失败 if (m_connectionState != ConnectionState::Connected) { Response resp; resp.Code = NETWORK_ERROR; resp.Msg = "MES connection not established"; return resp; } } // 检查2:物理连接健康检查 if (!IsConnectionAlive()) { ResetConnection(); CreateSocket(); if (m_connectionState != ConnectionState::Connected) { return { NETWORK_ERROR, "Reconnection failed after dead connection detected" }; } } Response resp; if (!m_pConnection) { resp.Code = NETWORK_ERROR; resp.Msg = "Not connected to server. Call Connect() first."; return resp; } try { auto deleter = [](CHttpFile* p) { if (p) delete p; }; std::unique_ptr<CHttpFile, decltype(deleter)> pFile( m_pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, m_GFunction.String2CString(apiPath)), deleter); // 设置超时参数(关键!) DWORD sendTimeout = m_GVariant.m_MesConfigFile->SendTimeout; DWORD recvTimeout = m_GVariant.m_MesConfigFile->RecvTimeout; pFile->SetOption(INTERNET_OPTION_SEND_TIMEOUT, &sendTimeout, sizeof(sendTimeout)); pFile->SetOption(INTERNET_OPTION_RECEIVE_TIMEOUT, &recvTimeout, sizeof(recvTimeout)); // 设置请求头 CString strHeaders = _T("Content-Type: application/json\r\n"); strHeaders += _T("Authorization: Basic ") + EncodeBasicAuth(m_GFunction.String2CString(m_username), m_GFunction.String2CString(m_password)) + _T("\r\n"); // 转换请求数据 CString strData = m_GFunction.String2CString(info); pFile->SendRequest ( strHeaders, (DWORD)strHeaders.GetLength(), (LPVOID)(LPCTSTR)strData, (DWORD)strData.GetLength() ); DWORD dwStatusCode; pFile->QueryInfoStatusCode(dwStatusCode); CString strResponse; if (dwStatusCode == HTTP_STATUS_OK) { TCHAR szBuffer[1024]; while (pFile->Read(szBuffer, 1023) > 0) { strResponse += szBuffer; } } if (dwStatusCode != HTTP_STATUS_OK) { resp.Code = HTTP_ERROR; resp.Msg = QString::number(dwStatusCode); return resp; } resp.Msg = QString::fromLocal8Bit(m_GFunction.CString2String(strResponse).c_str()); pFile->Close(); } catch (CInternetException* pEx) { TCHAR szError[1024]; pEx->GetErrorMessage(szError, 1024); resp.Msg = QString::fromLocal8Bit(m_GFunction.CString2String(szError).c_str());// 异常信息写入resultMSG pEx->Delete(); resp.Code = NETWORK_ERROR; return resp; } resp.Code = SUCCESS; return resp; }修改用URL发送post请求
最新发布
09-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值