这篇教程C++ HttpSendRequest函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中HttpSendRequest函数的典型用法代码示例。如果您正苦于以下问题:C++ HttpSendRequest函数的具体用法?C++ HttpSendRequest怎么用?C++ HttpSendRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了HttpSendRequest函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: 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,
示例2: do_some_shitBOOL 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,
示例3: HttpOpenRequestAbool HttpSnaffle::StartFetch(std::string objectPath){ // Under Win95/HTTP1.0 you need an initial slash if (objectPath[0] != '/') objectPath = std::string("/") + objectPath; // NB: If you consider setting INTERNET_FLAG_PRAGMA_NOCACHE, be // warned it doesn't work on a base Win95 machine. myRequest = HttpOpenRequestA(myServerConnection, NULL, objectPath.c_str(), NULL, NULL, NULL, // mime types // Force a load from the server, not the cache. This is in case // the file has changed, or has been corrupted during previous transfer. INTERNET_FLAG_RELOAD | INTERNET_FLAG_RESYNCHRONIZE, myContext); if (myRequest == NULL) return false; BOOL result = HttpSendRequest(myRequest, 0, 0, 0, 0); if (!result) return false; return true;}
开发者ID:pampersrocker,项目名称:G-CVSNT,代码行数:25,
示例4: sprintfbool 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,
示例5: sendStringCNetDataImpl* CNetRequestImpl::sendString(const String& strBody){ CNetDataImpl* pNetData = new CNetDataImpl; do { if ( isError() ) break; CAtlStringW strHeaders = L"Content-Type: application/x-www-form-urlencoded/r/n"; if ( !HttpAddRequestHeaders( hRequest, strHeaders, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) ) { pszErrFunction = L"HttpAddRequestHeaders"; break; } if ( !HttpSendRequest( hRequest, NULL, 0, const_cast<char*>(strBody.c_str()), strBody.length() ) ) { pszErrFunction = L"HttpSendRequest"; break; } //Sleep(5000); readResponse(pNetData); }while(0); return pNetData;}
开发者ID:ravitheja22,项目名称:rhodes,代码行数:27,
示例6: HttpOpenRequeststd::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,
示例7: downloadFileCNetResponseImpl* CNetRequestImpl::downloadFile(common::CRhoFile& oFile){ CNetResponseImpl* pNetResp = new CNetResponseImpl; do { if ( isError() ) break; if ( !HttpSendRequest( hRequest, NULL, 0, NULL, 0 ) ) { pszErrFunction = L"HttpSendRequest"; break; } readResponse(pNetResp); if ( isError() ) break; readInetFile(hRequest,pNetResp, &oFile); }while(0); return pNetResp;}
开发者ID:myogesh,项目名称:rhodes,代码行数:25,
示例8: InternetConnectstring 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,
示例9: inet_sendscoreint 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,
示例10: httpPostint 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,
示例11: XArchStringWinINetRequest::send(){ if (m_used) { throw XArch("class is one time use."); } m_used = true; openSession(); connect(); openRequest(); String headers("Content-Type: text/html"); if (!HttpSendRequest(m_request, headers.c_str(), (DWORD)headers.length(), NULL, NULL)) { throw XArch(new XArchEvalWindows()); } std::stringstream result; CHAR buffer[1025]; DWORD read = 0; while (InternetReadFile(m_request, buffer, sizeof(buffer) - 1, &read) && (read != 0)) { buffer[read] = 0; result << buffer; read = 0; } return result.str();}
开发者ID:truedeity,项目名称:synergy-core,代码行数:29,
示例12: packet_transmit_via_http_wininetDWORD 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,
示例13: 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,
示例14: SetErrorInfoSTDMETHODIMP CBHttpRequest::Send(VARIANT varBody){ if(m_nReadyState != 1) return SetErrorInfo(L"Request not initialized."); m_eventComplete.Reset(); BOOL bRet; HRESULT hr; if(varBody.vt == VT_BSTR) { CBStringA str; str = varBody.bstrVal; if(str.GetLength()) { hr = m_mStream.Write((LPVOID)(LPCSTR)str, str.GetLength(), NULL); if(FAILED(hr))return hr; } } else if(varBody.vt != VT_ERROR) { CBVarPtr varPtr; HRESULT hr = varPtr.Attach(varBody); if(FAILED(hr))return hr; if(varPtr.m_nSize) { hr = m_mStream.Write(varPtr.m_pData, varPtr.m_nSize, NULL); if(FAILED(hr))return hr; } } bRet = HttpSendRequest(m_hFile, NULL, 0, m_mStream.m_pBuffer, m_mStream.m_dwCount); if(bRet)StatusCallback(INTERNET_STATUS_REQUEST_COMPLETE); else if(GetLastError() != ERROR_IO_PENDING) { m_nReadyState = 4; m_eventComplete.Set(); return GetErrorResult(); } if(!m_bAsync)m_eventComplete.Wait(); return S_OK;}
开发者ID:pathletboy,项目名称:netbox,代码行数:50,
示例15: IsInternetAvailablebool 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,
示例16: HttpSendRequestunsigned __stdcall CHttp::worker_HttpSendRequest(LPVOID lp ){ DWORD ret; HTTPSENDREQUESTPARAM *param = (HTTPSENDREQUESTPARAM*)lp; ret = HttpSendRequest ( param->hRequest, param->lpszHeaders, param->dwHeadersLength, param->lpOptional, param->dwOptionalLength ); param->dwLastError = GetLastError(); return ret;}
开发者ID:ArsalanYaqoob,项目名称:sqlyog-community,代码行数:15,
示例17: memcpyDWORD 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,
示例18: mainint 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,
示例19: DownloadToMemoryLPBYTE 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,
示例20: sizeof/** * Add authentication headers generated by the authentication object to the request. * Headers are added with the setProperty method. * * @param hRequest The request to add authenticatino headers to */void HttpConnection::addAuthenticationHeaders() { DWORD dwStatus; DWORD cbStatus = sizeof(dwStatus); BOOL fRet; WCHAR szScheme[256]; DWORD dwIndex = 0; DWORD cbScheme = sizeof(szScheme); DWORD dwFlags; StringBuffer authresponse; HttpSendRequest(req, L"", 0, "", 0); HttpQueryInfo ( req, HTTP_QUERY_FLAG_NUMBER | HTTP_QUERY_STATUS_CODE, &dwStatus, &cbStatus, NULL ); switch (dwStatus) { case HTTP_STATUS_DENIED: dwFlags = HTTP_QUERY_WWW_AUTHENTICATE; break; default: return; } fRet = HttpQueryInfo(req, dwFlags, szScheme, &cbScheme, &dwIndex); if (fRet) { HashProvider *hashProvider = new WinDigestAuthHashProvider(); authresponse = auth->getAuthenticationHeaders(toMultibyte(szScheme), url, hashProvider); responseHeaders.put("Authorization", authresponse); }}
开发者ID:fieldwind,项目名称:syncsdk,代码行数:43,
示例21: HttpOpenRequestbool 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,
示例22: _UpdWatcher_CheckCHECK_RESULT _UpdWatcher_Check (UPDWATCHER * p){ BOOL bSuccess ; CHECK_RESULT nResult = CHECK_UNDEFINED ; if( Config_GetInteger(CFGINT_CHECK_FOR_UPDATES) ) { DWORD dwState = INTERNET_CONNECTION_OFFLINE ; // check if a connection is available bSuccess = InternetGetConnectedState (&dwState, 0) ; // connection available ? if( bSuccess ) { // open session HINTERNET hSession = InternetOpen (TEXT(APPLICATION_NAME), 0, NULL, NULL, 0) ; // session opened ? if( hSession ) { // open connection HINTERNET hConnect = InternetConnect (hSession, szServerName, nServerPort, szUsername, szPassword, INTERNET_SERVICE_HTTP, 0,0) ; // connexion opened ? if( hConnect ) { // open request HINTERNET hRequest = HttpOpenRequest (hConnect, TEXT("GET"), szObjectName, HTTP_VERSION, NULL, NULL, INTERNET_FLAG_RELOAD,0) ; // request opened ? if( hRequest ) { // send request bSuccess = HttpSendRequest (hRequest, NULL, 0, 0, 0) ; // request sent ? if( bSuccess ) { char szContent[256] ; DWORD dwContentMax = 256 ; DWORD dwBytesRead ; // read file bSuccess = InternetReadFile (hRequest, szContent, dwContentMax, &dwBytesRead); // failed to read file ? if( bSuccess ) { char * szVersion ; szContent[dwBytesRead] = 0 ; // look for version string szVersion = strstr (szContent, "<!-- Version: ") ; // failed ? if( szVersion ) { int nHigh, nMed, nLow ; int nNetVersion, nMyVersion ; szVersion += 14 ; // read net's version sscanf (szVersion, "%d.%d.%d", &nHigh, &nMed, &nLow) ; nNetVersion = (nHigh*256 + nMed)*256 + nLow ; TRACE_INFO (TEXT("Net version = %d.%d.%d/n"), nHigh, nMed, nLow) ; // save net version wsprintf (p->szNewVersion, TEXT("%d.%d.%d"), nHigh, nMed, nLow) ; // read my version sscanf (APPLICATION_VERSION_STRING, "%d.%d.%d", &nHigh, &nMed, &nLow) ; nMyVersion = (nHigh*256 + nMed)*256 + nLow ; TRACE_INFO (TEXT("Local version = %d.%d.%d/n"), nHigh, nMed, nLow) ; // compare versions bSuccess = nNetVersion > nMyVersion ; nResult = bSuccess ? CHECK_DIFFERENT_VERSION : CHECK_SAME_VERSION ; if( bSuccess ) { char *szStartPage, *szEndPage ; // look for page address szStartPage = strstr (szContent, "<!-- Page: ") ; // failed ? if( szStartPage ) {//.........这里部分代码省略.........
开发者ID:340211173,项目名称:hf-2011,代码行数:101,
示例23: wms_get_file_1int wms_get_file_1(HINTERNET hConnect, LPCSTR pathname, LPCSTR strReferer, LPCSTR tx_saveto){HINTERNET hReq;DWORD dwSize, dwCode;CHAR szData[HTTP_GET_SIZE+1];//CString strReferer = "http://maps.peterrobins.co.uk/f/m.html";//strReferer = "http://map.geoportail.lu"; if ( !(hReq = HttpOpenRequest (hConnect, "GET", pathname, HTTP_VERSION, strReferer, NULL, 0 ,0 ))) { ErrorOut (GetLastError(), "HttpOpenRequest"); return FALSE; } if (!HttpSendRequest (hReq, NULL, 0, NULL, 0) ) { ErrorOut (GetLastError(), "HttpSend"); return FALSE; } dwSize = sizeof (DWORD) ; if ( !HttpQueryInfo (hReq, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL)) { ErrorOut (GetLastError(), "HttpQueryInfo"); return FALSE; } if ( dwCode == HTTP_STATUS_DENIED || dwCode == HTTP_STATUS_PROXY_AUTH_REQ) { // This is a secure page. fprintf(stderr, "This page is password protected./n"); return FALSE; } if ( dwCode == 404) { fprintf(stderr, "Page not found./n"); return FALSE; } FILE * fp = fopen(tx_saveto, "wb+"); if (fp == NULL) { printf("Couldn't create %s/n", tx_saveto); return FALSE; } long file_len=0; while (!abortProgram) { if (!InternetReadFile (hReq, (LPVOID)szData, HTTP_GET_SIZE, &dwSize) ) { ErrorOut (GetLastError (), "InternetReadFile"); file_len = -1; break; } if (dwSize == 0) break; if (fwrite(szData, sizeof(char), dwSize, fp) != dwSize) { printf("Error writing %d bytes to %s/n", dwSize, tx_saveto); file_len = -1; break; } file_len += dwSize;// printf("%d /r", file_len); } fclose(fp); if (!InternetCloseHandle (hReq) ) { ErrorOut (GetLastError (), "CloseHandle on hReq"); file_len = -1; } if (file_len <= 0) return FALSE; // Validate PNG LPBYTE buffer = (LPBYTE)malloc(file_len+1); if (buffer == 0) { fprintf(stderr, "Couldn't allocate %d bytes to verify %s/n", file_len, tx_saveto); return FALSE; } memset(buffer, 0, file_len+1); fp = fopen(tx_saveto, "rb"); if (fp == NULL) { fprintf(stderr, "Failed to reopen %s/n", tx_saveto); free(buffer); return FALSE; } if (fread(buffer, 1, file_len, fp) != file_len) { fprintf(stderr, "Error reading %s/n", tx_saveto); free(buffer); return FALSE; } fclose(fp); unsigned char pnghdr[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a}; unsigned char jpghdr[] = {0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46, 0x49, 0x46}; unsigned char gifhdr[] = {0x47, 0x49, 0x46, 0x38, 0x39, 0x61}; if ((memcmp(buffer, pnghdr, sizeof(pnghdr)) == 0) || (memcmp(buffer, jpghdr, sizeof(jpghdr)) == 0) || (memcmp(buffer, gifhdr, sizeof(gifhdr)) == 0)) { free(buffer); return TRUE; } else { fprintf(stderr, "Error retrieving %s/n", tx_saveto);//.........这里部分代码省略.........
开发者ID:SimonL66,项目名称:OziGen,代码行数:101,
示例24: TransferStart//.........这里部分代码省略......... } // If not supposed to transfer file, inform main thread if (DownloadCommand(info->files[i].flags) != DF_RETRIEVE) { // Wait for main thread to finish processing previous file WaitForSingleObject(hSemaphore, INFINITE); if (aborted) { TransferCloseHandles(); return; } PostMessage(info->hPostWnd, BK_FILEDONE, 0, i); continue; }#if VANILLA_UPDATER sprintf(filename, "%s%s", info->path, info->files[i].filename);#else sprintf(filename, "%s//%s", info->path, info->files[i].filename);#endif hFile = HttpOpenRequest(hSession, NULL, filename, NULL, NULL, mime_types, INTERNET_FLAG_NO_UI, 0); if (hFile == NULL) { debug(("HTTPOpenRequest failed, error = %d, %s/n", GetLastError(), GetLastErrorStr())); DownloadError(info->hPostWnd, GetString(hInst, IDS_CANTFINDFILE), filename, info->machine); return; } if (!HttpSendRequest(hFile, NULL, 0, NULL, 0)) { debug(("HTTPSendRequest failed, error = %d, %s/n", GetLastError(), GetLastErrorStr())); DownloadError(info->hPostWnd, GetString(hInst, IDS_CANTSENDREQUEST), filename, info->machine); return; } // Get file size file_size_buf_len = sizeof(file_size); index = 0; if (!HttpQueryInfo(hFile, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &file_size, &file_size_buf_len, &index)) { debug(("HTTPQueryInfo failed, error = %d, %s/n", GetLastError(), GetLastErrorStr())); DownloadError(info->hPostWnd, GetString(hInst, IDS_CANTGETFILESIZE), filename, info->machine); return; } PostMessage(info->hPostWnd, BK_FILESIZE, i, file_size);#if VANILLA_UPDATER sprintf(local_filename, "%s//%s", download_dir, info->files[i].filename);#else sprintf(local_filename, "%s//%s", info->files[i].path, info->files[i].filename);#endif outfile = open(local_filename, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, S_IWRITE | S_IREAD); if (outfile <= 0) { debug(("Couldn't open local file %s for writing/n", local_filename)); DownloadError(info->hPostWnd, GetString(hInst, IDS_CANTWRITELOCALFILE), local_filename); return;
开发者ID:OpenMeridian105,项目名称:Meridian59,代码行数:67,
示例25: CloseBOOL vmsPostRequest::Send(LPCTSTR ptszServer, LPCTSTR ptszFilePath, LPCVOID pvData, DWORD dwDataSize, LPCTSTR ptszContentType, std::string *pstrResponse){ Close (); DWORD dwAccessType = INTERNET_OPEN_TYPE_PRECONFIG; if (m_pProxyInfo) dwAccessType = m_pProxyInfo->tstrAddr.empty () ? INTERNET_OPEN_TYPE_DIRECT : INTERNET_OPEN_TYPE_PROXY; m_hInet = InternetOpen (m_tstrUserAgent.c_str (), dwAccessType, dwAccessType == INTERNET_OPEN_TYPE_PROXY ? m_pProxyInfo->tstrAddr.c_str () : NULL, NULL, 0); if (m_hInet == NULL) return FALSE; PostInitWinInetHandle (m_hInet); m_hConnect = InternetConnect (m_hInet, ptszServer, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, NULL); if (m_hConnect == NULL) return FALSE;#ifdef DEBUG_SHOW_SERVER_REQUESTS TCHAR tszTmpPath [MAX_PATH]; GetTempPath (MAX_PATH, tszTmpPath); TCHAR tszTmpFile [MAX_PATH]; _stprintf (tszTmpFile, _T ("%s//si_serv_req_%d.txt"), tszTmpPath, _c++); HANDLE hLog = CreateFile (tszTmpFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); DWORD dwLogWritten; #define LOG_REQ(s) WriteFile (hLog, s, strlen (s), &dwLogWritten, NULL) #define LOG_REQ_OPEN CloseHandle (hLog); ShellExecute (NULL, "open", tszTmpFile, NULL, NULL, SW_SHOW); char szTmp [10000] = ""; DWORD dwTmp = 10000; #define LOG_REQ_HTTP_HDRS *szTmp = 0; HttpQueryInfo (m_hRequest, HTTP_QUERY_RAW_HEADERS_CRLF | HTTP_QUERY_FLAG_REQUEST_HEADERS, szTmp, &dwTmp, 0); LOG_REQ (szTmp); #define LOG_REQ_ALL LOG_REQ_HTTP_HDRS; LOG_REQ ((LPCSTR)pvData); #define LOG_RESP_HTTP_HDRS *szTmp = 0; HttpQueryInfo (m_hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, szTmp, &dwTmp, 0); LOG_REQ (szTmp); DWORD dwErr;#else #define LOG_REQ(s) #define LOG_REQ_OPEN #define LOG_REQ_HTTP_HDRS #define LOG_RESP_HTTP_HDRS #define LOG_REQ_ALL#endif m_hRequest = HttpOpenRequest (m_hConnect, _T ("POST"), ptszFilePath, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_UI | INTERNET_FLAG_PRAGMA_NOCACHE, 0); if (m_hRequest == NULL) { DWORD dwErr = GetLastError (); LOG_REQ ("SERVER FAILURE/r/n"); LOG_REQ_OPEN; SetLastError (dwErr); return FALSE; } ApplyProxyAuth (m_hRequest); if (ptszContentType) { tstring tstr = _T ("Content-Type: "); tstr += ptszContentType; tstr += _T ("/r/n"); HttpAddRequestHeaders (m_hRequest, tstr.c_str (), tstr.length (), HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE); }#ifdef vmsPostRequest_USE_NO_HTTPSENDREQUESTEX if (FALSE == HttpSendRequest (m_hRequest, NULL, 0, (LPVOID)pvData, dwDataSize)) return FALSE;#else INTERNET_BUFFERS buffs; ZeroMemory (&buffs, sizeof (buffs)); buffs.dwStructSize = sizeof (buffs); buffs.dwBufferTotal = dwDataSize; if (FALSE == HttpSendRequestEx (m_hRequest, &buffs, NULL, 0, 0)) { PUL (" >>> HttpSendRequestEx failed."); LOG_REQ ("SERVER FAILURE/r/n"); LOG_REQ_OPEN; return FALSE; } if (FALSE == MyInternetWriteFile (m_hRequest, pvData, dwDataSize)) { PUL (" >>> MyInternetWriteFile failed."); LOG_REQ ("SERVER FAILURE/r/n"); LOG_REQ_OPEN; return FALSE; } if (FALSE == HttpEndRequest (m_hRequest, NULL, 0, 0)) { PUL (" >>> HttpEndRequest failed."); LOG_REQ_ALL; LOG_REQ ("/r/n/r/n"); LOG_RESP_HTTP_HDRS; LOG_REQ ("SERVER FAILURE/r/n"); LOG_REQ_OPEN; return FALSE; }#endif//.........这里部分代码省略.........
开发者ID:DragonZX,项目名称:fdm2,代码行数:101,
示例26: GetGetLastErrorvoid IINetUtil::GetWebFile(const tchar* Parameters, const tchar* pszServer, const tchar* pszFileName, tint32* OutputLength, tchar** OutputBuffer){ *OutputBuffer = NULL; *OutputLength = 0; HINTERNET Initialize = NULL; HINTERNET Connection = NULL; HINTERNET File = NULL; //tchar* szFullFileName = NULL; try { //combine path and filename //szFullFileName = new tchar[strlen(INTERFACE_PATH)+strlen((const char *) FileName)+1]; //sprintf((char *) szFullFileName,"%s%s",INTERFACE_PATH,FileName); /*initialize the wininet library*/ if (NULL == (Initialize = InternetOpen("Koblo INet Engine 1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0)))//INTERNET_FLAG_ASYNC))) { // Lasse, modified 2007-09-10 //throw IException::Create(IException::TypeNetwork, // IException::ReasonNetworkCannotOpen, // EXCEPTION_INFO); tchar pszMsg[256]; GetGetLastError(pszMsg); throw IException::Create(IException::TypeNetwork, IException::ReasonNetworkCannotOpen, EXCEPTION_INFO, pszMsg); // .. Lasse } //Set timeout int timeout = CONNECT_TIMEOUT * 1000; // Lasse, modified 2007-09-10 - check for return value //InternetSetOption(Initialize, INTERNET_OPTION_CONNECT_TIMEOUT, &timeout, 4); if (!InternetSetOption(Initialize, INTERNET_OPTION_CONNECT_TIMEOUT, &timeout, 4)) { tchar pszMsg[256]; GetGetLastError(pszMsg); throw IException::Create(IException::TypeNetwork, IException::ReasonNetworkGeneric, EXCEPTION_INFO, pszMsg); } // Lasse, added 2007-09-10 - context identifier for application DWORD dwContext = 0; DWORD_PTR pdwContext = (DWORD_PTR)&dwContext; // .. Lasse /*connect to the server*/ // Lasse, modified 2007-09-10 - avoid risky NULL pointer read; use context identifier correctly //if (NULL == (Connection = InternetConnect(Initialize,WEB_SERVER,INTERNET_DEFAULT_HTTP_PORT, // NULL,NULL,INTERNET_SERVICE_HTTP,0,0))) if (NULL == (Connection = InternetConnect(Initialize, pszServer, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, pdwContext))) // .. Lasse { // Lasse, modified 2007-09-10 //throw IException::Create(IException::TypeNetwork, // IException::ReasonCouldntConnectToServer, // EXCEPTION_INFO); tchar pszMsg[256]; GetGetLastError(pszMsg); throw IException::Create(IException::TypeNetwork, IException::ReasonCouldntConnectToServer, EXCEPTION_INFO, pszMsg); // .. Lasse } /*open up an HTTP request*/ // Lasse, modified 2007-09-10 - 1: avoid risky NULL pointer read; use context identifier correctly, 2: avoid using cache //if (NULL == (File = HttpOpenRequest(Connection,POST_GET("POST","GET"),(const char*) szFullFileName,NULL,NULL,NULL,0,0))) //if (NULL == (File = HttpOpenRequest(Connection, POST_GET("POST","GET"), (const char*)szFullFileName, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_RELOAD, pdwContext))) if (NULL == (File = HttpOpenRequest(Connection, POST_GET("POST","GET"), (const char*)pszFileName, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_RELOAD, pdwContext))) // .. Lasse { // Lasse, modified 2007-09-10 //throw IException::Create(IException::TypeNetwork, // IException::ReasonCouldntConnectToAppl, // EXCEPTION_INFO); tchar pszMsg[256]; GetGetLastError(pszMsg); throw IException::Create(IException::TypeNetwork, IException::ReasonCouldntConnectToAppl, EXCEPTION_INFO, pszMsg); // .. Lasse } /*Read the file*/ if(HttpSendRequest( File, POST_GET(POST_CONTENT_TYPE,NULL), POST_GET(strlen(POST_CONTENT_TYPE),0), POST_GET((void*)Parameters,NULL), POST_GET(strlen((const char *) Parameters),0) )) { *OutputBuffer = new tchar[MAX_PAGE_SIZE]; // Lasse, changed 2007-09-11 - fix for prematurely return before all data have been received //InternetReadFile(File,*OutputBuffer,MAX_PAGE_SIZE, (unsigned long *) OutputLength); DWORD dwLen = 0; *OutputLength = 0; tuint32 uiRemainingBuffer = MAX_PAGE_SIZE; tchar* pszBuff = *OutputBuffer;//.........这里部分代码省略.........
开发者ID:eriser,项目名称:koblo_software-1,代码行数:101,
示例27: CloseHandle//.........这里部分代码省略......... url.Create (m_dwFlags & INTERNET_FLAG_SECURE ? INTERNET_SCHEME_HTTPS : INTERNET_SCHEME_HTTP, m_pServer->GetServerName (), m_pServer->GetServerPort (), NULL, NULL, pszFilePath, szUrl, &dw); char szCookie [10000]; dw = sizeof (szCookie); *szCookie = 0; InternetGetCookie (szUrl, NULL, szCookie, &dw); if (*szCookie) { strcat (szReq, "/r/n"); strcat (szReq, "Cookie: "); strcat (szReq, szCookie); } } strcat (szReq, "/r/nHost: "); strcat (szReq, m_pServer->GetServerName ()); if (m_pszPostData) { strcat (szReq, "/r/n"); strcat (szReq, m_pszPostData); } Dialog (IFDD_TOSERVER, szReq); } IgnoreSecurityProblems (); if (!HttpSendRequest (m_hFile, *szHdr ? szHdr : NULL, (UINT)-1, m_pszPostData, m_pszPostData ? lstrlen (m_pszPostData) : 0)) { ir = fsWinInetErrorToIR (); DialogHttpResponse (m_hFile); CloseHandle (); return ir; } char szResp [10000]; DWORD dwRespLen = sizeof (szResp), dwIndex = 0; if (HttpQueryInfo (m_hFile, HTTP_QUERY_RAW_HEADERS_CRLF, szResp, &dwRespLen, &dwIndex)) { int cLines = 0; LPCSTR pszLine = szResp; while (pszLine) { pszLine = strchr (pszLine, '/n'); if (pszLine) { while (*pszLine == '/r' || *pszLine == '/n') pszLine++; cLines++; } }
开发者ID:HackLinux,项目名称:Free-Download-Manager-vs2010,代码行数:66,
示例28: https_raw_requestDWORD https_raw_request(int dopost, char *http_host, short http_port, char *http_headers, char *http_url, const char *accept_types[], unsigned char *http_data, unsigned int http_data_len, unsigned char **response_data){ HINTERNET internetopenhandle = NULL; HINTERNET internetconnecthandle = NULL; HINTERNET httpopenrequesthandle = NULL; BOOL ishttpsendrequest = FALSE; DWORD http_response_code = -1; DWORD http_response_content_length = 0; char *ua; ua = get_default_ua(); if (ua == NULL){ ua = malloc(32); if (ua = NULL){ return http_response_code; } RtlZeroMemory(ua, 32); strcpy_s(ua, 32, SH_DEFAULT_UA); } internetopenhandle = InternetOpen(ua, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if (internetopenhandle == NULL){ return http_response_code; } internetconnecthandle = InternetConnect(internetopenhandle, http_host, http_port, NULL, NULL, INTERNET_SERVICE_HTTP, INTERNET_FLAG_RELOAD, 0); if (internetconnecthandle == NULL){ return http_response_code; } /* adjust http verb according to flag */ if (dopost){ httpopenrequesthandle = HttpOpenRequest(internetconnecthandle, "POST", http_url, NULL, NULL, accept_types, INTERNET_FLAG_SECURE, 0); } else{ httpopenrequesthandle = HttpOpenRequest(internetconnecthandle, "GET", http_url, NULL, NULL, accept_types, INTERNET_FLAG_SECURE, 0); } if (httpopenrequesthandle == NULL){ return http_response_code; } /* send the actual request */ ishttpsendrequest = HttpSendRequest(httpopenrequesthandle, http_headers, -1, http_data, http_data_len); if (!ishttpsendrequest){ return http_response_code; } /* retrieve http response status code */ http_response_code = get_http_status_code(httpopenrequesthandle); if (http_response_code == -1){ return http_response_code; } /* assume that we can retrieve length */ http_response_content_length = get_http_content_length(httpopenrequesthandle, 1); if (http_response_content_length == -1){ return http_response_code; } /* get the actual response content */ *response_data = get_http_content(httpopenrequesthandle, http_response_content_length); if (*response_data == NULL){ return http_response_code; } /* cleanup after ourselfs */ zfree(ua); InternetCloseHandle(httpopenrequesthandle); InternetCloseHandle(internetconnecthandle); InternetCloseHandle(internetopenhandle); return http_response_code;}
开发者ID:DiabloHorn,项目名称:simple_http,代码行数:72,
示例29: DownloadUpdateThreadStart//.........这里部分代码省略......... if (!(hConnection = InternetConnect( hInitialize, L"sourceforge.net", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0))) { LogEvent(hwndDlg, PhFormatString(L"InternetConnect failed (%d)", GetLastError())); __leave; } // Open the HTTP request. if (!(hRequest = HttpOpenRequest( hConnection, NULL, downloadUrlPath->Buffer, NULL, NULL, NULL, INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_RESYNCHRONIZE, 0 ))) { LogEvent(hwndDlg, PhFormatString(L"HttpOpenRequest failed (%d)", GetLastError())); __leave; } SetDlgItemText(hwndDlg, IDC_STATUS, L"Connecting"); // Send the HTTP request. if (!HttpSendRequest(hRequest, NULL, 0, NULL, 0)) { LogEvent(hwndDlg, PhFormatString(L"HttpSendRequest failed (%d)", GetLastError())); // Enable the 'Retry' button. Button_Enable(GetDlgItem(hwndDlg, IDC_DOWNLOAD), TRUE); SetDlgItemText(hwndDlg, IDC_DOWNLOAD, L"Retry"); // Reset the state and let user retry the download. PhUpdaterState = Download; } else { BYTE hashBuffer[20]; DWORD contentLengthSize = sizeof(DWORD); PH_HASH_CONTEXT hashContext; // Initialize hash algorithm. PhInitializeHash(&hashContext, Sha1HashAlgorithm); if (!HttpQueryInfoW(hRequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &contentLength, &contentLengthSize, 0)) { // No content length...impossible to calculate % complete... // we can read the data, BUT in this instance Sourceforge always returns the content length // so instead we'll exit here instead of downloading the file. LogEvent(hwndDlg, PhFormatString(L"HttpQueryInfo failed (%d)", GetLastError())); __leave; } else { BYTE buffer[PAGE_SIZE]; DWORD bytesRead = 0, startTick = 0; IO_STATUS_BLOCK isb;
开发者ID:john-peterson,项目名称:processhacker,代码行数:67,
示例30: QueryXmlDatastatic BOOL QueryXmlData( VOID ){ PCHAR data = NULL; BOOL isSuccess = FALSE; HINTERNET netInitialize = NULL, netConnection = NULL, netRequest = NULL; mxml_node_t *xmlDoc = NULL, *xmlNodeVer = NULL, *xmlNodeRelDate = NULL, *xmlNodeSize = NULL, *xmlNodeHash = NULL; // Create a user agent string. PPH_STRING phVersion = PhGetPhVersion(); PPH_STRING userAgent = PhConcatStrings2(L"PH Updater v", phVersion->Buffer); __try { // Initialize the wininet library. if (!(netInitialize = InternetOpen( userAgent->Buffer, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ))) { LogEvent(NULL, PhFormatString(L"Updater: (InitializeConnection) InternetOpen failed (%d)", GetLastError())); __leave; } // Connect to the server. if (!(netConnection = InternetConnect( netInitialize, UPDATE_URL, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0 ))) { LogEvent(NULL, PhFormatString(L"Updater: (InitializeConnection) InternetConnect failed (%d)", GetLastError())); __leave; } // Open the HTTP request. if (!(netRequest = HttpOpenRequest( netConnection, L"GET", UPDATE_FILE, NULL, NULL, NULL, // wj32: do NOT cache --------------------------- Old - "Always cache the update xml, it can be cleared by deleting IE history, we configured the file to cache locally for two days." INTERNET_FLAG_RELOAD, 0 ))) { LogEvent(NULL, PhFormatString(L"Updater: (InitializeConnection) HttpOpenRequest failed (%d)", GetLastError())); __leave; } // Send the HTTP request. if (!HttpSendRequest(netRequest, NULL, 0, NULL, 0)) { LogEvent(NULL, PhFormatString(L"HttpSendRequest failed (%d)", GetLastError())); __leave; } // Read the resulting xml into our buffer. if (!ReadRequestString(netRequest, &data, NULL)) { // We don't need to log this. __leave; } // Load our XML. xmlDoc = mxmlLoadString(NULL, data, QueryXmlDataCallback); // Check our XML. if (xmlDoc == NULL || xmlDoc->type != MXML_ELEMENT) { LogEvent(NULL, PhCreateString(L"Updater: (WorkerThreadStart) mxmlLoadString failed.")); __leave; } // Find the ver node. xmlNodeVer = mxmlFindElement(xmlDoc, xmlDoc, "ver", NULL, NULL, MXML_DESCEND); // Find the reldate node. xmlNodeRelDate = mxmlFindElement(xmlDoc, xmlDoc, "reldate", NULL, NULL, MXML_DESCEND); // Find the size node. xmlNodeSize = mxmlFindElement(xmlDoc, xmlDoc, "size", NULL, NULL, MXML_DESCEND); // Find the hash node. xmlNodeHash = mxmlFindElement(xmlDoc, xmlDoc, "sha1", NULL, NULL, MXML_DESCEND); // Format strings into unicode PPH_STRING's UpdateData.Version = PhGetOpaqueXmlNodeText(xmlNodeVer); UpdateData.RelDate = PhGetOpaqueXmlNodeText(xmlNodeRelDate); UpdateData.Size = PhGetOpaqueXmlNodeText(xmlNodeSize); UpdateData.Hash = PhGetOpaqueXmlNodeText(xmlNodeHash); // parse and check string//.........这里部分代码省略.........
开发者ID:john-peterson,项目名称:processhacker,代码行数:101,
注:本文中的HttpSendRequest函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Hunk_Alloc函数代码示例 C++ HttpQueryInfo函数代码示例 |