当前位置: 首页>>代码示例>>C++>>正文


C++ CUrl类代码示例

本文整理汇总了C++中CUrl的典型用法代码示例。如果您正苦于以下问题:C++ CUrl类的具体用法?C++ CUrl怎么用?C++ CUrl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CUrl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnButtonAdd

/*
	OnButtonAdd()
*/
void CWallPaperCrawlerSettingsDomainDlg::OnButtonAdd(void)
{
	char szValue[MAX_URL+1];

	UpdateData(TRUE);
	strcpyn(szValue,m_strValue,sizeof(szValue));

	CUrl url;
	URL Url;

	// controlla che non contenga caratteri jolly
	if(strchr(szValue,'?') || strchr(szValue,'*'))
	{
		::MessageBoxResourceEx(this->m_hWnd,MB_OK|MB_ICONERROR,WALLPAPER_PROGRAM_NAME,IDS_ERROR_WILDCARDS,szValue);
		return;
	}

	// controlla che sia un url
	if(!url.IsUrl(szValue))
	{
		::MessageBoxResourceEx(this->m_hWnd,MB_OK|MB_ICONERROR,WALLPAPER_PROGRAM_NAME,IDS_ERROR_INVALID_HTTP_URL,szValue);
		return;
	}
		
	// controlla che sia un url HTTP
	if(!url.IsUrlType(szValue,HTTP_URL))
	{
		if(::MessageBoxResourceEx(this->m_hWnd,MB_YESNO|MB_ICONQUESTION,WALLPAPER_PROGRAM_NAME,IDS_QUESTION_INVALID_HTTP_URL,szValue)==IDNO)
			return;
	}

	// elimina l'eventuale '/' finale
	int nLen = strlen(szValue)-1;
	if(szValue[nLen]=='/')
		szValue[nLen] = '\0';

	url.SplitUrl(szValue,&Url);
	BOOL bOnlyHost = TRUE;
	if(strlen(Url.file) > 0)
		bOnlyHost = FALSE;
	if(strlen(Url.dir) > 0)
		if(strcmp(Url.dir,"/")!=0)
			bOnlyHost = FALSE;
	if(!bOnlyHost)
	{
		::MessageBoxResourceEx(this->m_hWnd,MB_OK|MB_ICONERROR,WALLPAPER_PROGRAM_NAME,IDS_ERROR_NOT_HTTP_DOMAIN,szValue,strlen(Url.file) > 0 ? Url.file : Url.dir,Url.host);
		strcpyn(szValue,Url.host,sizeof(szValue));
	}

	if(strlen(szValue) > 0)
	{
		if(m_wndDomainList.FindItem(szValue) < 0)
			m_wndDomainList.SelectItem(m_wndDomainList.AddItem(szValue,0));
		else
			::MessageBoxResourceEx(this->m_hWnd,MB_OK|MB_ICONERROR,WALLPAPER_PROGRAM_NAME,IDS_ERROR_VALUE_EXISTS,szValue);
	}
	else
		::MessageBoxResource(this->m_hWnd,MB_OK|MB_ICONERROR,WALLPAPER_PROGRAM_NAME,IDS_ERROR_INVALID_VALUE);
}
开发者ID:code4bones,项目名称:crawlpaper,代码行数:62,代码来源:WallPaperCrawlerSettingsDomainDlg.cpp

示例2: call_wirte_func

/*
 * 将请求返回的结果打印输出到屏幕.
 */
long CUrl::call_wirte_func(void *buffer, int size, int nmemb, void *uri)
{

	long count = size * nmemb;
	
	Uri *puri = (Uri *)uri;
	CUrl *pcurl = (CUrl *)puri->pcurl;


	if (pcurl != 0 && pcurl->isfirstwirte == true)
	{
		pcurl->get_response_code();
		pcurl->get_response_length();
		pcurl->get_response_contenttype();

		puri->request_size =	pcurl->request_size;
		puri->request_cursize =	0;
	}

	if (pcurl->request_size > 0)
	{
		if (puri->curbuf == NULL)
		{
			puri->curbuf = (char *)malloc(pcurl->request_size+1);
		}
		memcpy(puri->curbuf + puri->request_cursize,(const char *)buffer, count);
		puri->request_cursize += count;
		//puri->curbuf_allocsize = pcurl->request_size;
		puri->curbuf_size += count;
		puri->curbuf[puri->request_size] = 0;
	}
	else
	{
		if (puri->curbuf == NULL)
		{
			puri->curbuf = (char *)malloc(count+1);
			memcpy(puri->curbuf, buffer, count);
			puri->request_cursize = count;
			puri->request_size = count;
			//puri->curbuf_allocsize = count;
			puri->curbuf_size = count;
		} 
		else
		{
			puri->curbuf = (char *)realloc(puri->curbuf, puri->request_size + count+1);
			memcpy(puri->curbuf + puri->request_size , buffer, count);
			puri->request_cursize += count;
			puri->request_size += count;
			//puri->curbuf_allocsize += count;
			puri->curbuf_size += count;
		}
		puri->curbuf[puri->request_size] = 0;
	}

	pcurl->isfirstwirte = false;
	return count;
}
开发者ID:Cryptos-Numisma,项目名称:rest,代码行数:60,代码来源:curl.cpp

示例3: Requset

void Uri::Requset()
{
	if(isinit == true)
	{
		CUrl curl;
		curl.requset(this);
		pcurl = 0;
	}
	return ;
};
开发者ID:Cryptos-Numisma,项目名称:rest,代码行数:10,代码来源:uri.cpp

示例4: new

EXPORT_C CUrl* CUrl::NewL(const TParseBase& aFileName)
//
//	Static factory c'tor. Used for creating CUrl object for a file on local file system
	{
	CUrl* url = new(ELeave) CUrl();
	CleanupStack::PushL(url);
	url->ConstructL(aFileName);
	CleanupStack::Pop();
	return url;	
	}
开发者ID:kuailexs,项目名称:symbiandump-mw2,代码行数:10,代码来源:URLBASE.cpp

示例5: CurrentlyListed

bool CManagedUrlList::CurrentlyListed(CUrl Url) {
	// If the url is in the list of urls to visit, then we already know about it
	for (std::list<CUrl>::iterator j = this->begin(); j != this->end(); j++) {
		CUrl Current = *j;
		// ### This will have to be more specific to match the server too
		if (Url.GetResource() == Current.GetResource()) return true;
	}

	// Didn't find it in the list
	return false;
}
开发者ID:fsakbas,项目名称:crawwwler,代码行数:11,代码来源:ManagedUrlList.cpp

示例6: PreviouslyListed

bool CManagedUrlList::PreviouslyListed(CUrl Url) {
	// If the url is in the list of visited resources, then we've been there
	for (std::list<CUrl>::iterator i = m_PastItems.begin(); i != m_PastItems.end(); i++) {
		CUrl Current = *i;
		// ### This will have to be more specific to match the server too
		if (Current.GetResource() == Url.GetResource()) {
			// Already been there
			return true;
		}
	}
	// Couldn't find it
	return false;
}
开发者ID:fsakbas,项目名称:crawwwler,代码行数:13,代码来源:ManagedUrlList.cpp

示例7: Post

int CHttpRequest::Post(CUrl& iUrl, const CString& RawData){
  CString Server;
  int Port;  		       
  if (ProxyURL.StrLength() && Proxy.isValid()) {
    Server = Proxy.GetHost();
    Port = Proxy.GetPortValue();
  } else if (iUrl.isValid()) {
    Server = iUrl.GetHost();
    Port = iUrl.GetPortValue();
  } else return 0;
  inetSocket Sock(Port, Server);
  if (wsLastError.StrLength()) return 0;
  char iE[] = "xxxx\0"; sprintf(iE, "%c%c", 13, 10);  
  return PostHTTP(iUrl, RawData, iE, Sock);
}
开发者ID:dblock,项目名称:agnes,代码行数:15,代码来源:chttprequest.cpp

示例8: Execute

int CHttpRequest::Execute(CUrl& iUrl){
#ifdef _U_DEBUG
    cout << "CHttpRequest::Execute()" << endl;
#endif

    RHeader.Free();
    RData.Free();
    RStatus.Free();
    RStatusValue = -1;
    RedirectVector.Clear();

    CString Server;
    int Port;       
    if (ProxyURL.StrLength() && Proxy.isValid()) {
      Server = Proxy.GetHost();
      Port = Proxy.GetPortValue();
    } else if (iUrl.isValid()) {
      Server = iUrl.GetHost();
      Port = iUrl.GetPortValue();
    } else {
      RStatusValue = HTTPR_USER + 1;
      return 0;
    }
#ifdef _U_DEBUG
    cout << "CHttpRequest::Execute() - creating inetSocket" << endl;
#endif
    inetSocket Sock(Port, Server);
    if (wsLastError.StrLength()) {
#ifdef _U_DEBUG
      cout << "CHttpRequest::Execute() - ERROR at inetSocket - " << wsLastError << endl;
#endif
      RStatusValue = HTTPR_USER + 2;      
      return 0;
    }
#ifdef _U_DEBUG
    cout << "CHttpRequest::Execute() - inetSocket created" << endl;
#endif
    char iE[] = "xxxx\0"; sprintf(iE, "%c%c", 13, 10);  
    
    if (!GetHTTP10(iUrl, iE, Sock)) {
      if (!GetHTTP09(iUrl, iE, Sock)) {
	return 0;
      } else return 1;
    }
    else return 1;
}
开发者ID:dblock,项目名称:agnes,代码行数:46,代码来源:chttprequest.cpp

示例9: connect

bool CHttpConnection::connect(const CUrl &url) {
/*
** Host und Port aus CUrl holen
*/
  string host=url.getDomain();
  string sport=url.getPort();
  unsigned int port;

  if(sport=="")
    port=80;
  else
    port=atol(sport.c_str());
/*
** connect für Host und Port aufrufen
*/
  return(connect(host,port));
}
开发者ID:Info2-Projekt,项目名称:Matritzen-Rechner,代码行数:17,代码来源:CHttpConnection.cpp

示例10: ProcessData

int CHttpRequest::GetHTTP09(CUrl& iUrl, const CString& iE, inetSocket& Sock){
  /*
    attempt a retrieval of HTTP/0.9
    */  
  CString Request;  
  if (RLimit) Request += "GET "; else Request+="HEAD ";
  Request += iUrl.GetScheme(); Request+="://";
  Request += iUrl.GetHost();
  if (iUrl.GetPortValue() != 80) {
    Request+=":"; 
    Request += iUrl.GetPort();
  }
  Request += iUrl.GetUrlPath(); Request+=iE;  
  for (int i=0;i<RHeaderParams.entries_count();i++) {
    Request+=RHeaderParams.get_name(i);
    Request+=": ";
    Request+=RHeaderParams.get_value(i);
    Request += iE;
  }
  Request += iE;
#ifdef _U_DEBUG
  cout << "# HTTP 0.9 Request: =====" << endl;
  cout << Request;
  cout << "=====================" << endl;
#endif
  /*
    issue request
    */
  if (!Send(Sock, Request)) return 0;
  RHeader.Free();
  RData.Free();
  RStatus.Free();
  RStatusValue = -1;
  ProcessData(Sock);
  if (RData.StrLength()) {
    RHeaderResponse.clear();
    RStatusValue = 200;
    RStatus = "200";
    return 1;
  } else if (RStatusValue != -1) {
    return 0;
  } else {
    RStatusValue = HTTPR_USER + 3;
    return 0;
  }
}
开发者ID:dblock,项目名称:agnes,代码行数:46,代码来源:chttprequest.cpp

示例11: PostHTTP

int CHttpRequest::PostHTTP(CUrl& iUrl, const CString& RawData, const CString& iE, inetSocket& Sock){
  CString Request;
  if (ProxyURL.StrLength() && Proxy.isValid()) {
    Request += "POST "; Request += iUrl.GetScheme(); Request+="://";
    Request += iUrl.GetHost(); 
    if (iUrl.GetPortValue() != 80) {
      Request+=":"; 
      Request += iUrl.GetPort();
    }
    Request += iUrl.GetUrlPath(); Request += " HTTP/1.0"; Request+=iE;    
  } else {
    Request += "POST "; Request += iUrl.GetUrlPath(); Request += " HTTP/1.0"; Request+=iE;
    Request += "Host: "; Request += iUrl.GetHost(); Request+=iE;
  }
  for (int i=0;i<RHeaderParams.entries_count();i++) {
    Request+=RHeaderParams.get_name(i);
    Request+=": ";
    Request+=RHeaderParams.get_value(i);
    Request += iE;
  }
  Request += iE;
  Request += RawData;
  if (!Send(Sock, Request)) return 0;
  ProcessHeader(Sock);
  ProcessData(Sock);
  if (RData.StrLength()) {
    RHeaderResponse.clear();
    RStatusValue = 200;
    RStatus = "200";
    return 1;
  } else return 0;
}
开发者ID:dblock,项目名称:agnes,代码行数:32,代码来源:chttprequest.cpp

示例12: Perform

void CUrlManager::Perform()
{
	for (unordered_set<CUrl*>::iterator it = m_sUrl.begin(); it != m_sUrl.end(); )
	{
		CUrl* pUrl = *it;
		pUrl->m_eMultiCode = curl_multi_perform(pUrl->m_pCurlm, &pUrl->m_nStillRunning);
		if (pUrl->m_eMultiCode > CURLM_OK || pUrl->m_nStillRunning == 0)
		{
			pUrl->OnWriteOver();
			it = m_sUrl.erase(it);
			delete pUrl;
		}
		else
		{
			++it;
		}
	}
}
开发者ID:dnasdw,项目名称:3dstool,代码行数:18,代码来源:url_manager.cpp

示例13: doLogin

int FetcherManager::doLogin(CURL *curl, Task *task, UrlNode *urlnode) {
    InfoCrawler *infocrawler = InfoCrawler::getInstance();
    TaskOtherInfo *taskother = infocrawler->getTaskScheduleManager()->getTaskOtherInfo(task->id);
    if (!taskother) {
        return -1;
    }
    if (!task) {
        return -1;
    }
    CUrl url;
    url.parse(task->loginurl);

    if (url.getUrl().empty()) {
        return -1;
    }

    HttpProtocol httpprotocol;
    char downstatistic[512] ;
    downstatistic[0] = 0;
    RESPONSE_HEADER rheader;

    mylog_info(m_pLogGlobalCtrl->infolog, "before login %s - %s:%s:%d",url.getUrl().c_str(),INFO_LOG_SUFFIX);
    int ret = httpprotocol.curl_login(curl, url, urlnode, infocrawler->getConf()->httptimeout, &rheader, downstatistic);
    mylog_info(m_pLogGlobalCtrl->infolog, "after login  %s %s %d - %s:%s:%d",url.getUrl().c_str(), downstatistic, ret,INFO_LOG_SUFFIX);
    /* if (ret == HTTP_FETCH_RET_REDIRECT) { //redirect
         errorlog("LOGIN ERROR: fetched %s  relocated to %s taskid %d\n", url.getUrl().c_str() ,(char *)page.m_sLocation.c_str(),task->id);
     } else*/
    if (ret == HTTP_FETCH_RET_ERROR) {//just discard
        mylog_error(m_pLogGlobalCtrl->errorlog, "login fetched %s taskid %d - %s:%s:%d:%d", url.getUrl().c_str(), task->id,INFO_LOG_SUFFIX,ret);
    } else if (ret == HTTP_FETCH_RET_ERROR_INVALIDHOST) { //invalid host, can not access
        mylog_error(m_pLogGlobalCtrl->errorlog, "login fetched %s taskid %d - %s:%s:%d:%d", url.getUrl().c_str(), task->id,INFO_LOG_SUFFIX,ret);
    } else if (ret == HTTP_FETCH_RET_ERROR_UNACCEPTED) { //content is invalid, discard
        mylog_error(m_pLogGlobalCtrl->errorlog, "LOGIN fetched %s unaccepted contenttyped %s taskid %d - %s:%s:%d:%d", url.getUrl().c_str(), rheader.contenttype.c_str(), task->id,INFO_LOG_SUFFIX,ret);
    } else
    {
        taskother->fetchingcookie = true;
        static char *loginok = "LOGIN OK";
        saveCookie(task->id, loginok, strlen(loginok));
        taskother->fetchingcookie = false;
        return 1;
    }
    return -1;
}
开发者ID:codrocker,项目名称:bloomServer,代码行数:43,代码来源:FetcherManager.cpp

示例14: Compare

EXPORT_C TInt CUrl::Compare(CUrl& aUrl, TInt aCompareComps) const
//
//	Scheme is case insensitive, rest of url is case sensitive
	{
	TInt result =0;
	if (aCompareComps & EUrlScheme)
		{
		result += Component(EUrlScheme).CompareF(aUrl.Component(EUrlScheme));
		if (result !=0)
			return result;
		}
		
	if (aCompareComps & EUrlLocation)
		{
		result += Component(EUrlLocation).Compare(aUrl.Component(EUrlLocation));
		if (result !=0)
			return result;
		}

	if (aCompareComps & EUrlUsername)
		{
		result += Component(EUrlUsername).Compare(aUrl.Component(EUrlUsername));
		if (result !=0)
			return result;
		}

	if (aCompareComps & EUrlPassword)
		{
		result += Component(EUrlPassword).Compare(aUrl.Component(EUrlPassword));
		if (result !=0)
			return result;
		}

	if (aCompareComps & EUrlPath)
		{
		result += Component(EUrlPath).Compare(aUrl.Component(EUrlPath));
		if (result !=0)
			return result;
		}

	if (aCompareComps & EUrlQuery)
		{
		result += Component(EUrlQuery).Compare(aUrl.Component(EUrlQuery));
		if (result !=0)
			return result;
		}

	if (aCompareComps & EUrlFragment)
		{
		result += Component(EUrlFragment).Compare(aUrl.Component(EUrlFragment));
		if (result !=0)
			return result;
		}
	return result;
	}
开发者ID:kuailexs,项目名称:symbiandump-mw2,代码行数:55,代码来源:URLBASE.cpp

示例15: Execute

bool CHttpRequest::Execute(const CUrl& Url) {
    Trace(tagHttp, levInfo, ("CHttpRequest - CHttpRequest {%s}", Url.GetBrute().GetBuffer()));
    m_Url = Url;
    ClearResults(true);
    switch(m_RequestMethod) {
    case htPost:
        assert(0);
        if (CreateSocket()) {
        }
        break;
    case htGet:
        if (m_RequestSizeLimit == 0) m_RequestMethod = htHead;
    case htHead:
        return (ExecuteGet(true) != -1);
    default:
        return false;
    }
    return false;
}
开发者ID:dblock,项目名称:baseclasses,代码行数:19,代码来源:HttpRequest.cpp


注:本文中的CUrl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。