本文整理汇总了C++中HttpOpenRequest函数的典型用法代码示例。如果您正苦于以下问题:C++ HttpOpenRequest函数的具体用法?C++ HttpOpenRequest怎么用?C++ HttpOpenRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HttpOpenRequest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: InternetConnect
string Functions::HttpGet(LPCWSTR uri, HINTERNET hHandle, LPCWSTR host)
{
HINTERNET cHandle = InternetConnect(hHandle, host, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
HINTERNET oHandle = HttpOpenRequest(cHandle, L"GET", uri, L"HTTP/1.1", NULL, NULL, INTERNET_FLAG_RELOAD, 0);
BOOL sHandle = HttpSendRequest(oHandle, L"", 0, 0, 0);
if(sHandle)
{
char* buffer = (char*) malloc(sizeof(char) * (1024));
DWORD dwVal = 0;
BOOL eHandle = InternetReadFile(oHandle, buffer, 1024, &dwVal);
if(eHandle)
{
char* buffer2 = (char*) malloc(sizeof(char) * (dwVal + 1));
buffer2[dwVal] = '\0';
memcpy(buffer2, buffer, dwVal);
string str = string(buffer2);
free(buffer);
free(buffer2);
return str;
}
free(buffer);
}
return "";
}
开发者ID:Gabrola,项目名称:gProxy,代码行数:27,代码来源:Functions.cpp
示例2: memset
CNetRequestImpl::CNetRequestImpl(const char* method, const String& strUrl)
{
pszErrFunction = NULL;
hInet = NULL, hConnection = NULL, hRequest = NULL;
memset(&uri, 0, sizeof(uri) );
m_pInstance = this;
CAtlStringW strUrlW(strUrl.c_str());
do
{
if ( !isLocalHost(strUrl.c_str()) && !SetupInternetConnection(strUrlW) )
{
pszErrFunction = L"SetupInternetConnection";
break;
}
hInet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
if ( !hInet )
{
pszErrFunction = L"InternetOpen";
break;
}
DWORD dwUrlLength = 1024;
CAtlStringW strCanonicalUrlW;
if ( !InternetCanonicalizeUrl( strUrlW, strCanonicalUrlW.GetBuffer(dwUrlLength), &dwUrlLength, 0) )
{
pszErrFunction = _T("InternetCanonicalizeUrl");
break;
}
strCanonicalUrlW.ReleaseBuffer();
alloc_url_components( &uri, strCanonicalUrlW );
if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &uri ) )
{
pszErrFunction = L"InternetCrackUrl";
break;
}
hConnection = InternetConnect( hInet, uri.lpszHostName, uri.nPort, _T("anonymous"), NULL,
INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
pszErrFunction = L"InternetConnect";
break;
}
strReqUrlW = uri.lpszUrlPath;
strReqUrlW += uri.lpszExtraInfo;
hRequest = HttpOpenRequest( hConnection, CAtlStringW(method), strReqUrlW, NULL, NULL, NULL,
INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE, NULL );
if ( !hRequest )
{
pszErrFunction = L"HttpOpenRequest";
break;
}
}while(0);
}
开发者ID:ravitheja22,项目名称:rhodes,代码行数:60,代码来源:NetRequestImpl.cpp
示例3: httpPost
int httpPost(url_schema *urls, const char *headers, const char *data)
{
int rc = 0;
static const TCHAR agent[] = _T("Google Chrome");
static LPCTSTR proxy = NULL;
static LPCTSTR proxy_bypass = NULL;
HINTERNET hSession = InternetOpen(agent, PRE_CONFIG_INTERNET_ACCESS, proxy, proxy_bypass, 0);
if (hSession) {
HINTERNET hConnect = InternetConnect(hSession, urls->host, urls->port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
if (hConnect) {
PCTSTR accept[] = {"*/*", NULL};
HINTERNET hRequest = HttpOpenRequest(hConnect, _T("POST"), urls->page, NULL, NULL, accept, 0, 1);
if (hRequest) {
if (!HttpSendRequest(hRequest, headers, lstrlen(headers), (LPVOID)data, lstrlen(data)))
rc = ERROR_SEND_REQUEST;
else
rc = ERROR_SUCCESS;
InternetCloseHandle(hRequest);
}
else
rc = ERROR_OPEN_REQUEST;
InternetCloseHandle(hConnect);
}
else
rc = ERROR_CONNECT;
InternetCloseHandle(hSession);
}
else
rc = ERROR_INTERNET;
return rc;
}
开发者ID:hellomotor,项目名称:hisinfopost,代码行数:33,代码来源:hisinfopost.cpp
示例4: inet_sendscore
int inet_sendscore(char *name, char *scorecode)
{
char url[1000];
int result=INET_SUCCESS;
HINTERNET data;
// Create request URL
sprintf(url,"/highscore.php?yourname=%s&code=%s",name,scorecode);
// Open request
data = HttpOpenRequest(connection, "GET", url, "HTTP/1.0", NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0 );
if(data!=NULL)
{
// Send data
if(HttpSendRequest(data, NULL, 0, NULL, 0)) InternetCloseHandle(data);
else result = INET_SENDREQUEST_FAILED;
}
else
{
result = INET_OPENREQUEST_FAILED;
}
return(result);
}
开发者ID:basuradeluis,项目名称:Alien8RemakeSRC,代码行数:25,代码来源:internet.c
示例5: WWWFileBuffer
//download file from WWW in a buffer
bool WWWFileBuffer(char *host, char *path, char *outBuffer, int outBufferSize)
{
bool retval = false;
LPTSTR AcceptTypes[2] = { TEXT("*/*"), NULL };
DWORD dwSize = outBufferSize - 1, dwFlags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE;
HINTERNET opn = NULL, con = NULL, req = NULL;
opn = InternetOpen(TEXT("Evilzone.org"), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (!opn)
return retval;
con = InternetConnect(opn, host, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if (!con)
return retval;
req = HttpOpenRequest(con, TEXT("GET"), path, HTTP_VERSION, NULL, (LPCTSTR*)AcceptTypes, dwFlags, 0);
if (!req)
return retval;
if (HttpSendRequest(req, NULL, 0, NULL, 0))
{
DWORD statCodeLen = sizeof(DWORD);
DWORD statCode;
if (HttpQueryInfo(req,
HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
&statCode, &statCodeLen, NULL))
{
if (statCode == 200 && InternetReadFile(req, (LPVOID)outBuffer, outBufferSize - 1, &dwSize))
{
retval = TRUE;
}
}
}
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(opn);
return retval;
}
开发者ID:piaoasd123,项目名称:Fwankie,代码行数:35,代码来源:Server.cpp
示例6: do_some_shit
BOOL do_some_shit()
{
HINTERNET Initialize,Connection,File;
DWORD BytesRead;
Initialize = InternetOpen(_T("HTTPGET"),INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
Connection = InternetConnect(Initialize,_T("www.clicksaw.com"),INTERNET_DEFAULT_HTTP_PORT, NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
File = HttpOpenRequest(Connection,NULL,_T("/contact.html"),NULL,NULL,NULL,0,0);
if(HttpSendRequest(File,NULL,0,NULL,0))
{
LPSTR szContents[400] = { '\0' } ; // = Contents.GetBuffer(400);
while(InternetReadFile(File, szContents, 400, &BytesRead) && BytesRead != 0)
{
}
MessageBoxA(NULL, (LPCSTR)(szContents), "metoo", NULL);
}
InternetCloseHandle(File);
InternetCloseHandle(Connection);
InternetCloseHandle(Initialize);
return(TRUE);
}
开发者ID:eyberg,项目名称:syse,代码行数:26,代码来源:syse.cpp
示例7: HttpOpenRequest
std::string WebIO::Execute(const char* command, std::string body)
{
WebIO::OpenConnection();
const char *acceptTypes[] = { "application/x-www-form-urlencoded", NULL };
DWORD dwFlag = INTERNET_FLAG_RELOAD | (WebIO::IsSecuredConnection() ? INTERNET_FLAG_SECURE : 0);
WebIO::m_hFile = HttpOpenRequest(WebIO::m_hConnect, command, WebIO::m_sUrl.document.c_str(), NULL, NULL, acceptTypes, dwFlag, 0);
HttpSendRequest(WebIO::m_hFile, "Content-type: application/x-www-form-urlencoded", -1, (char*)body.c_str(), body.size() + 1);
std::string returnBuffer;
DWORD size = 0;
char buffer[0x2001] = { 0 };
while (InternetReadFile(WebIO::m_hFile, buffer, 0x2000, &size))
{
returnBuffer.append(buffer, size);
if (!size) break;
}
WebIO::CloseConnection();
return returnBuffer;
}
开发者ID:Convery,项目名称:SteamBase,代码行数:26,代码来源:WebIO.cpp
示例8: sprintf
bool CHttpHelper::publish(char *payload)
{
bool result = false;
DWORD flags = INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_PRAGMA_NOCACHE;
char path[1024];
int len = sprintf(path, "%s", m_routerSettings->routerPath);
sprintf(path + len, "%s", m_topic);
HINTERNET httpRequest = HttpOpenRequest(m_hSession,
"POST",
path,
NULL,
"pocketnoc",
NULL,
flags,
0);
if(httpRequest == NULL)
return result;
if(HttpSendRequest(httpRequest, NULL, 0, payload, strlen(payload)))
result = true;
InternetCloseHandle(httpRequest);
return result;
}
开发者ID:kragen,项目名称:mod_pubsub,代码行数:30,代码来源:HttpHelper.cpp
示例9: openHTTPConnection
void openHTTPConnection (URL_COMPONENTS& uc, URL::OpenStreamProgressCallback* progressCallback,
void* progressCallbackContext)
{
const TCHAR* mimeTypes[] = { _T("*/*"), 0 };
DWORD flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES;
if (address.startsWithIgnoreCase ("https:"))
flags |= INTERNET_FLAG_SECURE; // (this flag only seems necessary if the OS is running IE6 -
// IE7 seems to automatically work out when it's https)
request = HttpOpenRequest (connection, isPost ? _T("POST") : _T("GET"),
uc.lpszUrlPath, 0, 0, mimeTypes, flags, 0);
if (request != 0)
{
INTERNET_BUFFERS buffers = { 0 };
buffers.dwStructSize = sizeof (INTERNET_BUFFERS);
buffers.lpcszHeader = headers.toWideCharPointer();
buffers.dwHeadersLength = (DWORD) headers.length();
buffers.dwBufferTotal = (DWORD) postData.getSize();
if (HttpSendRequestEx (request, &buffers, 0, HSR_INITIATE, 0))
{
int bytesSent = 0;
for (;;)
{
const int bytesToDo = jmin (1024, (int) postData.getSize() - bytesSent);
DWORD bytesDone = 0;
if (bytesToDo > 0
&& ! InternetWriteFile (request,
static_cast <const char*> (postData.getData()) + bytesSent,
(DWORD) bytesToDo, &bytesDone))
{
break;
}
if (bytesToDo == 0 || (int) bytesDone < bytesToDo)
{
if (HttpEndRequest (request, 0, 0, 0))
return;
break;
}
bytesSent += bytesDone;
if (progressCallback != nullptr
&& ! progressCallback (progressCallbackContext, bytesSent, (int) postData.getSize()))
break;
}
}
}
close();
}
开发者ID:Amcut,项目名称:pizmidi,代码行数:58,代码来源:juce_win32_Network.cpp
示例10: InternetSetOptionEx
int CPostData::TransferDataPost()
{
CUrlCrack url;
if (!url.Crack(m_strUrl.c_str()))
return ERR_URLCRACKERROR;
m_hInetSession = ::InternetOpen(MONEYHUB_USERAGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (m_hInetSession == NULL)
return ERR_NETWORKERROR;
DWORD dwTimeOut = 60000;
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONNECT_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
m_hInetConnection = ::InternetConnect(m_hInetSession, url.GetHostName(), url.GetPort(), NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD)this);
if (m_hInetConnection == NULL)
{
CloseHandles();
return ERR_NETWORKERROR;
}
LPCTSTR ppszAcceptTypes[2];
ppszAcceptTypes[0] = _T("*/*");
ppszAcceptTypes[1] = NULL;
m_hInetFile = HttpOpenRequest(m_hInetConnection, _T("POST"), url.GetPath(), NULL, NULL, ppszAcceptTypes, INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_KEEP_CONNECTION, (DWORD)this);
if (m_hInetFile == NULL)
{
CloseHandles();
return ERR_NETWORKERROR;
}
HttpAddRequestHeaders(m_hInetFile, _T("Content-Type: application/x-www-form-urlencoded\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
HttpAddRequestHeaders(m_hInetFile, _T("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
TCHAR szHeaders[1024];
_stprintf_s(szHeaders, _countof(szHeaders), _T("MoneyhubUID: %s\r\n"), m_strHWID.c_str());
HttpAddRequestHeaders(m_hInetFile, szHeaders, -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
BOOL bSend = ::HttpSendRequest(m_hInetFile, NULL, 0, m_lpPostData, m_dwPostDataLength);
if (!bSend)
{
CloseHandles();
return ERR_NETWORKERROR;
}
CloseHandles();
return ERR_SUCCESS;
}
开发者ID:Williamzuckerberg,项目名称:chtmoneyhub,代码行数:56,代码来源:postData.cpp
示例11: packet_transmit_via_http_wininet
DWORD packet_transmit_via_http_wininet(Remote *remote, Packet *packet, PacketRequestCompletion *completion) {
DWORD res = 0;
HINTERNET hReq;
HINTERNET hRes;
DWORD retries = 5;
DWORD flags;
DWORD flen;
unsigned char *buffer;
flen = sizeof(flags);
buffer = malloc( packet->payloadLength + sizeof(TlvHeader) );
if (! buffer) {
SetLastError(ERROR_NOT_FOUND);
return 0;
}
memcpy(buffer, &packet->header, sizeof(TlvHeader));
memcpy(buffer + sizeof(TlvHeader), packet->payload, packet->payloadLength);
do {
flags = INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_AUTO_REDIRECT | INTERNET_FLAG_NO_UI;
if (remote->transport == METERPRETER_TRANSPORT_HTTPS) {
flags |= INTERNET_FLAG_SECURE | INTERNET_FLAG_IGNORE_CERT_CN_INVALID | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID;
}
hReq = HttpOpenRequest(remote->hConnection, "POST", remote->uri, NULL, NULL, NULL, flags, 0);
if (hReq == NULL) {
dprintf("[PACKET RECEIVE] Failed HttpOpenRequest: %d", GetLastError());
SetLastError(ERROR_NOT_FOUND);
break;
}
if (remote->transport == METERPRETER_TRANSPORT_HTTPS) {
InternetQueryOption( hReq, INTERNET_OPTION_SECURITY_FLAGS, &flags, &flen);
flags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA | SECURITY_FLAG_IGNORE_CERT_CN_INVALID | SECURITY_FLAG_IGNORE_UNKNOWN_CA;
InternetSetOption(hReq, INTERNET_OPTION_SECURITY_FLAGS, &flags, flen);
}
hRes = HttpSendRequest(hReq, NULL, 0, buffer, packet->payloadLength + sizeof(TlvHeader) );
if (! hRes) {
dprintf("[PACKET RECEIVE] Failed HttpSendRequest: %d", GetLastError());
SetLastError(ERROR_NOT_FOUND);
break;
}
} while(0);
memset(buffer, 0, packet->payloadLength + sizeof(TlvHeader));
InternetCloseHandle(hReq);
return res;
}
开发者ID:2uro,项目名称:metasploit-4.-.-,代码行数:54,代码来源:core.c
示例12: GetCSRFToken
//------------------------------------------------------------------------------
void GetCSRFToken(VIRUSTOTAL_STR *vts)
{
HINTERNET M_connexion = 0;
if (!use_other_proxy)M_connexion = InternetOpen("",/*INTERNET_OPEN_TYPE_DIRECT*/INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
else M_connexion = InternetOpen("",/*INTERNET_OPEN_TYPE_DIRECT*/INTERNET_OPEN_TYPE_PROXY, proxy_ch_auth, NULL, 0);
if (M_connexion==NULL)M_connexion = InternetOpen("",INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
if (M_connexion==NULL)return;
//init connexion
HINTERNET M_session = InternetConnect(M_connexion, "www.virustotal.com",443,"","",INTERNET_SERVICE_HTTP,0,0);
if (M_session==NULL)
{
InternetCloseHandle(M_connexion);
return;
}
//connexion
HINTERNET M_requete = HttpOpenRequest(M_session,"GET","www.virustotal.com",NULL,"",NULL,
INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_SECURE
|INTERNET_FLAG_IGNORE_CERT_CN_INVALID|INTERNET_FLAG_IGNORE_CERT_DATE_INVALID,0);
if (use_proxy_advanced_settings)
{
InternetSetOption(M_requete,INTERNET_OPTION_PROXY_USERNAME,proxy_ch_user,sizeof(proxy_ch_user));
InternetSetOption(M_requete,INTERNET_OPTION_PROXY_PASSWORD,proxy_ch_password,sizeof(proxy_ch_password));
}
if (M_requete==NULL)
{
InternetCloseHandle(M_session);
InternetCloseHandle(M_connexion);
return;
}else if (HttpSendRequest(M_requete, NULL, 0, NULL, 0))
{
//traitement !!!
char buffer[MAX_PATH];
DWORD dwNumberOfBytesRead = MAX_PATH;
if(HttpQueryInfo(M_requete,HTTP_QUERY_SET_COOKIE, buffer, &dwNumberOfBytesRead, 0))
{
if (dwNumberOfBytesRead>42)buffer[42]=0;
//on passe : csrftoken=
strcpy(vts->token,buffer+10);
}
InternetCloseHandle(M_requete);
}
//close
InternetCloseHandle(M_session);
InternetCloseHandle(M_connexion);
}
开发者ID:lukevoliveir,项目名称:omnia-projetcs,代码行数:53,代码来源:tools_virustotal.c
示例13: IsInternetAvailable
bool CHTTPParser::HTTPGet(LPCTSTR pstrServer, LPCTSTR pstrObjectName, CString& rString)
{
bool bReturn = false;
// are we already connected
bReturn = IsInternetAvailable();
if(!bReturn)
{
// no, then try and connect
bReturn = openInternet();
}
if(bReturn == true)
{
HINTERNET hConnect = InternetConnect(m_hSession, pstrServer, 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
if(hConnect != NULL)
{
HINTERNET hFile = NULL;
hFile = HttpOpenRequest(hConnect, _T("GET"), pstrObjectName, HTTP_VERSION, NULL, NULL, INTERNET_FLAG_EXISTING_CONNECT, 1);
if(hFile != NULL)
{
if(HttpSendRequest(hFile, NULL, 0, NULL, 0))
{
readString(rString, hFile);
}
else
{
bReturn = false;
}
InternetCloseHandle(hFile);
}
else
{
bReturn = false;
}
InternetCloseHandle(hConnect);
}
else
{
bReturn = false;
}
}
return bReturn;
}
开发者ID:openxtra,项目名称:hotspot-sdk,代码行数:49,代码来源:HTTPParser.cpp
示例14: Abort
STDMETHODIMP CBHttpRequest::Open(BSTR strMethod, BSTR strUrl, VARIANT_BOOL bAsync, VARIANT varUser, VARIANT varPassword)
{
CUrl url;
CStringA strObject;
CStringA strUser;
CStringA strPassword;
Abort();
s_cs.Enter();
s_dwReqID ++;
m_dwReqID = s_dwReqID;
s_mapReq.SetAt(m_dwReqID, this);
s_cs.Leave();
url.CrackUrl(CBStringA(strUrl));
m_bAsync = (bAsync != VARIANT_FALSE);
strObject = url.GetUrlPath();
strObject.Append(url.GetExtraInfo());
if(varUser.vt != VT_ERROR)
{
HRESULT hr = varGetString(varUser, strUser);
if(FAILED(hr))return hr;
}
if(varPassword.vt != VT_ERROR)
{
HRESULT hr = varGetString(varPassword, strPassword);
if(FAILED(hr))return hr;
}
m_hConnection = InternetConnect(m_hSession, url.GetHostName(), url.GetPortNumber(),
strUser.IsEmpty() ? NULL : (LPCSTR)strUser, strPassword.IsEmpty() ? NULL : (LPCSTR)strPassword,
INTERNET_SERVICE_HTTP, 0, m_dwReqID);
if(m_hConnection == NULL)
return GetErrorResult();
m_hFile = HttpOpenRequest(m_hConnection, CBStringA(strMethod), strObject, NULL, NULL, NULL, m_dwFlags, m_dwReqID);
if(m_hFile == NULL)
return GetErrorResult();
m_eventComplete.Set();
return S_OK;
}
开发者ID:pathletboy,项目名称:netbox,代码行数:47,代码来源:BHttpRequest.cpp
示例15: HttpOpenRequest
void
WinINetRequest::openRequest()
{
m_request = HttpOpenRequest(
m_connect,
"GET",
m_url.m_path.c_str(),
HTTP_VERSION,
NULL,
NULL,
m_url.m_flags,
NULL);
if (m_request == NULL) {
throw XArch(new XArchEvalWindows());
}
}
开发者ID:truedeity,项目名称:synergy-core,代码行数:17,代码来源:ArchInternetWindows.cpp
示例16: memcpy
DWORD OS::GetComputerIp(char* ip, int type)
{
if (LOCALE_IP == type)
{
DWORD m_HostIP = 0;
LPHOSTENT lphost;
char HostName[1024];
if(!gethostname(HostName, 1024))
{
if(lphost = gethostbyname(HostName))
m_HostIP = ((LPIN_ADDR)lphost->h_addr)->s_addr;
}
/* if (ip)
memcpy(ip, inet_ntoa(*((in_addr*)lphost->h_addr_list[0])), MAX_IP_SIZE);*/
return m_HostIP;
}
else
{
HINTERNET hInet = InternetOpen("Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.0; .NET CLR 1.0.2914)",
INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
if (NULL != hInet)
{
HINTERNET hSession = InternetConnect(hInet, SERVER_IP_LOCALE, INTERNET_DEFAULT_HTTP_PORT, 0, 0,
INTERNET_SERVICE_HTTP, 0, 0);
if (NULL != hSession)
{
HINTERNET hRequest = HttpOpenRequest(hSession, "GET", "/get_ip.php?loc=", 0, 0, 0, INTERNET_FLAG_KEEP_CONNECTION, 1);
if (NULL == hRequest)
return 0;
if (HttpSendRequest(hRequest, 0, 0, 0, 0))
{
char szReadBuff[MAX_SITE_SIZE];
DWORD dwRead;
InternetReadFile(hRequest, szReadBuff, sizeof(szReadBuff) - 1, &dwRead);
if (0 == dwRead)
return 0;
ParseIpinHtml(szReadBuff, ip);
}
}
}
}
return 0;
}
开发者ID:alex-rassanov,项目名称:system-for-test-of-security,代码行数:45,代码来源:OS.cpp
示例17: main
int main()
{
HINTERNET session=InternetOpen("uniquesession",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0);
HINTERNET http=InternetConnect(session,"localhost",80,0,0,INTERNET_SERVICE_HTTP,0,0);
HINTERNET hHttpRequest = HttpOpenRequest(http,"POST","p.php",0,0,0,INTERNET_FLAG_RELOAD,0);
char szHeaders[] = "Content-Type: application/x-www-form-urlencoded; charset=UTF-8";
char szReq[1024]="cmd=winfuckinginet";
HttpSendRequest(hHttpRequest, szHeaders, strlen(szHeaders), szReq, strlen(szReq));
char szBuffer[1025];
DWORD dwRead=0;
while(InternetReadFile(hHttpRequest, szBuffer, sizeof(szBuffer)-1, &dwRead) && dwRead) {
szBuffer[dwRead] = '\0';
MessageBox(0,szBuffer,0,0);
}
InternetCloseHandle(hHttpRequest);
InternetCloseHandle(session);
InternetCloseHandle(http);
}
开发者ID:Raslin777,项目名称:snippets,代码行数:18,代码来源:wininet.c
示例18: DownloadToMemory
LPBYTE DownloadToMemory(IN LPCTSTR lpszURL, OUT PDWORD_PTR lpSize)
{
LPBYTE lpszReturn = 0;
*lpSize = 0;
const HINTERNET hSession = InternetOpen(TEXT("GetGitHubRepositoryList"), INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_NO_COOKIES);
if (hSession)
{
URL_COMPONENTS uc = { 0 };
TCHAR HostName[MAX_PATH];
TCHAR UrlPath[MAX_PATH];
uc.dwStructSize = sizeof(uc);
uc.lpszHostName = HostName;
uc.lpszUrlPath = UrlPath;
uc.dwHostNameLength = MAX_PATH;
uc.dwUrlPathLength = MAX_PATH;
InternetCrackUrl(lpszURL, 0, 0, &uc);
const HINTERNET hConnection = InternetConnect(hSession, HostName, INTERNET_DEFAULT_HTTPS_PORT, 0, 0, INTERNET_SERVICE_HTTP, 0, 0);
if (hConnection)
{
const HINTERNET hRequest = HttpOpenRequest(hConnection, TEXT("GET"), UrlPath, 0, 0, 0, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
if (hRequest)
{
HttpSendRequest(hRequest, 0, 0, 0, 0);
lpszReturn = (LPBYTE)GlobalAlloc(GMEM_FIXED, 1);
DWORD dwRead;
static BYTE szBuf[1024 * 4];
LPBYTE lpTmp;
for (;;)
{
if (!InternetReadFile(hRequest, szBuf, (DWORD)sizeof(szBuf), &dwRead) || !dwRead) break;
lpTmp = (LPBYTE)GlobalReAlloc(lpszReturn, (SIZE_T)(*lpSize + dwRead), GMEM_MOVEABLE);
if (lpTmp == NULL) break;
lpszReturn = lpTmp;
CopyMemory(lpszReturn + *lpSize, szBuf, dwRead);
*lpSize += dwRead;
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hConnection);
}
InternetCloseHandle(hSession);
}
return lpszReturn;
}
开发者ID:kenjinote,项目名称:GetGitHubRepositoryList,代码行数:44,代码来源:Source.cpp
示例19: switch
Request::Request(const oConnection& connection, const StringRef& uri, Type type, const char* version, const char* referer, const char** acceptTypes, int flags) {
this->_uri = RegEx::doReplace("#^[a-z]+://[^/]+#i" , "", uri.c_str() );
this->_type = type;
this->_connection = connection;
const char* verb;
switch (_type) {
case typePost:
verb = "POST";
break;
case typeHead:
verb = "HEAD";
break;
default:
verb = "GET";
}
_hRequest = HttpOpenRequest(connection->getHandle(), verb,
_uri.empty() ? "/" : _uri.c_str(), version, referer, acceptTypes, flags, 1);
if (!_hRequest) {
throw ExceptionBadRequest();
}
}
开发者ID:Konnekt,项目名称:staminalib,代码行数:21,代码来源:Internet.cpp
示例20: HttpOpenRequest
bool CConnection::SendRequest(XMLMemoryWriter& xml_memory_writer,Buffer &buffer,IEventListener* event_listener)
{
CHAR buffer_tmp[1024];
DWORD bytes_read;
const WCHAR* lplpszAcceptTypes[] = { L"*/*", NULL };
m_request = HttpOpenRequest(m_connection, L"POST", L"/xml-rpc", NULL, 0, lplpszAcceptTypes, 0, 0);
if (m_request)
{
if (HttpSendRequest(m_request, 0, 0, xml_memory_writer.xml_data, xml_memory_writer.xml_data_size))
{
DWORD content_len;
DWORD content_len_size = sizeof(content_len);
if (HttpQueryInfo(m_request, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &content_len, &content_len_size, 0))
{
if (buffer.Allocate(content_len))
{
while (InternetReadFile(m_request, buffer_tmp, sizeof(buffer_tmp), &bytes_read) && bytes_read)
{
memcpy(buffer.buffer_in + buffer.buffer_in_total, buffer_tmp, bytes_read);
buffer.buffer_in_total += bytes_read;
}
return true;
}
else
event_listener->OnError(L"failed to allocate memory");
}
else
event_listener->OnError(L"failed to query http info");
}
else
event_listener->OnError(L"failed to send http request");
InternetCloseHandle(m_request);
}
else
event_listener->OnError(L"failed creating http request");
return false;
}
开发者ID:iuliua,项目名称:OpenSub,代码行数:37,代码来源:CConnection.cpp
注:本文中的HttpOpenRequest函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论