CodePudding user response:
Use the interface implementation in the libcurl library, https://www.cnblogs.com/heluan/p/10177475.htmlCodePudding user response:
GET/index. HTTP/1.1 HTMBehind are some headers, Accept encoding and so on
CodePudding user response:
USES libcurl library will not use ah, put a piece of code that can access the server always return who help myself, be urgent!CInternetSession m_cis;//used to create and initialize the Internet session yyf
CHttpConnection * m_pHttp;//for the HTTP service
Cstrings m_strIP, m_appliURL m_strIniPath;
INTERNET_PORT m_strport=80;
M_strIP="127.0.0.1";
M_appliURL="https://idserver.xxxkj.com";//the server address
If (m_appliURL. IsEmpty ())
{
//CHXcertinterfaceCtrl: : m_Geterror="connection address is empty";
return 2;
}
//DWORD dwType=AFX_INET_SERVICE_HTTPS;//the Internet server type
//AfxParseURL (m_appliURL, dwType m_strIP, m_strIniPath, m_strport);
//if (dwType!=AFX_INET_SERVICE_HTTP)
//{
////CHXcertinterfaceCtrl: : m_Geterror="connection URL is not begin with HTTP://";
//return 3;
//}
Cstrings SendInfo="client_id=Vuees& Client_secret=secret& The username=w001 & amp; Password=123123 & amp; Grant_type=password ";
M_strIniPath="https://idserver.xxxkj.com/connect/token?" ;
M_strIniPath=m_strIniPath + SendInfo;
M_cis. SetOption (INTERNET_OPTION_CONNECT_TIMEOUT, 5);//is used to specify the requirements set Internet options
M_cis. SetOption (INTERNET_OPTION_CLIENT_CERT_CONTEXT, 0);
M_pHttp=m_cis. GetHttpConnection (m_strIP m_strport);//is used to establish a HTTP connection, return a ChttpConnection function
CHttpFile * pFile=m_pHttp - & gt; OpenRequest (CHttpConnection: : HTTP_VERB_POST,
M_strIniPath, NULL, 1, NULL, NULL, INTERNET_FLAG_EXISTING_CONNECT);//open the HTTP server connection
DWORD dwRet=0;
DWORD szBuffer=0;
DWORD dwBufferSize=sizeof (szBuffer);
Try {
PFile - & gt; The SendRequest ();//send the request to the HTTP
PFile - & gt; QueryInfo (HTTP_QUERY_STATUS_TEXT, szBuffer, & amp; DwBufferSize);
PFile - & gt; QueryInfoStatusCode (dwRet);
} the catch (CInternetException * pEx)
{
TCHAR szError [1024].
PEx - & gt; GetErrorMessage (szError, 1024);
AfxMessageBox (szError);
PFile - & gt; Close ();
}
If (dwRet==HTTP_STATUS_OK)
{
Cstrings result, newline;
While (pFile - & gt; ReadString (newline))
{//loop reads each line
The result +=newline + "\ r \ n";
}
STD: : cout
}
CodePudding user response:
Always returns 404 this is the result of return<body bgcolor="white" & gt;