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


C++ CUrl::GetUrlPath方法代码示例

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


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

示例1: 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

示例2: Open

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

示例3: 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

示例4:

CVector<CString> CUrlTree::UrlToVector(const CUrl& Url) const {
    CVector<CString> Vector;
    
    CString MidString;
    
    MidString += Url.GetScheme();
    MidString += ":/";
    
#ifdef _UNIX
    if (Url.GetScheme().Same(g_strProto_FILE)) {
        MidString += "/";
    }       
#endif
    
    Vector += MidString;
           
    MidString = Url.GetHost();
    
    if (MidString.GetLength() && Url.GetPortValue() != 80) {
        MidString += ":";
        MidString += Url.GetPort();
    }
    
    if (MidString.GetLength()) {
        Vector += MidString;
    }
    
    int HostVectorSize = Vector.GetSize();
    CVector<CString> Vector2;
    CString::StrToVector(Url.GetUrlPath(), '/', &Vector2);
    
    Vector += Vector2;
    
    if (((int) Vector.GetSize() > HostVectorSize) && (!Vector[HostVectorSize].GetLength())) 
        Vector.RemoveAt(HostVectorSize);
    
    return Vector;
}
开发者ID:dblock,项目名称:baseclasses,代码行数:38,代码来源:UrlTree.cpp

示例5: UrlUnescapeInPlace

HRESULT FAsyncDownload::FHttpDownloadTP::ProcessDownload(FAsyncDownData *pData)
{
    HRESULT hr = E_FAIL; 


    FString ReqUrl = pData->m_pUrlInfo->m_DownloadUrl;
    UrlUnescapeInPlace(ReqUrl.GetBuffer(), 0); 

    CUrl url;
    url.CrackUrl(ReqUrl);

	const tchar* pszUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)";
    FHInternet hIn = NULL; 
	if (g_AppSettings.m_Proxy.GetLength() > 0)
	{
		hIn = InternetOpen(pszUserAgent, INTERNET_OPEN_TYPE_PROXY, g_AppSettings.m_Proxy, g_AppSettings.m_ProxyA, 0);
	}
	else
	{
		hIn = InternetOpen(pszUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	}

     
    if (NULL == hIn)
        return E_HTTP_NET_ERROR; 

    FHInternet hCon = InternetConnect(hIn, url.GetHostName(), url.GetPortNumber(), url.GetUserName(), url.GetPassword(), INTERNET_SERVICE_HTTP, 0, 0); 

    if (NULL == hCon)
    {
        _DBGAlert("**FAsyncDownload::FHttpDownloadTP::ProcessDownload: InternetConnect() failed: %d\n", GetLastError()); 
        return E_HTTP_NET_ERROR; 
    }

	ULONG ulRecvTimeout = 15000; 
	InternetSetOption(hCon, INTERNET_OPTION_RECEIVE_TIMEOUT, &ulRecvTimeout, sizeof(ULONG));


    FString StrRes = url.GetUrlPath();
    StrRes+= url.GetExtraInfo(); 
    
    FHInternet hReq = HttpOpenRequest(hCon, "GET", StrRes, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_DONT_CACHE, 0); 

    if (NULL == hReq)
    {
        _DBGAlert("**FAsyncDownload::FHttpDownloadTP::ProcessDownload: HttpOpenRequest() failed: %d\n", GetLastError()); 
        return E_HTTP_NET_ERROR; 
    }

	size_type FileSize = 0;
	
	

	if (!(pData->m_pUrlInfo->m_dwDownloadFlags & HTTP_FLAG_NO_RESUME))
		FileSize = GetFileSize(pData->m_pUrlInfo->m_DownloadFile);

    // See if file already exists on the disk.
    if (FileSize > 0)
    {
        FString StrRange; 
        StrRange.Format("Range: bytes=%I64d-", FileSize); 
        HttpAddRequestHeaders(hReq, StrRange, StrRange.GetLength(), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
    }


	FString StrVersion; 
	StrVersion.Format("LTV_VERSION: %s", g_AppSettings.m_AppVersion); 
	HttpAddRequestHeaders(hReq, StrVersion, StrVersion.GetLength(), HTTP_ADDREQ_FLAG_ADD_IF_NEW);

    if (!HttpSendRequest(hReq, NULL, 0, NULL, 0))
    {
		int err = GetLastError(); 
        _DBGAlert("**FAsyncDownload::FHttpDownloadTP::ProcessDownload: HttpSendRequest() failed: %d (0x%x)\n", err, HRESULT_FROM_WIN32(err)); 
        InternetCloseHandle(hCon);
        InternetCloseHandle(hIn); 
        return E_HTTP_NET_ERROR; 
    }

    const DWORD dwBufferSize = 8192;
    char pBuffer[dwBufferSize];

    FHttpConnection FConn = hReq;

    DWORD dwStatusCode = FConn.GetStatusCode(); 

	FString ReqContentType = pData->m_pUrlInfo->m_ContentType; 
	pData->m_pUrlInfo->m_ContentType = FConn.GetHeader(HTTP_QUERY_CONTENT_TYPE);
	pData->m_pUrlInfo->m_dwStatusCode = dwStatusCode; 

	if (!MatchContentType(ReqContentType, pData->m_pUrlInfo->m_ContentType))
	{
		_DBGAlert("**FAsyncDownload::FHttpDownloadTP::ProcessDownload: Content type mismatch: %s/%s\n", ReqContentType, pData->m_pUrlInfo->m_ContentType); 
		return E_NOINTERFACE; //E_NOINTERFACE = content type mismatch
	}

	if (dwStatusCode == 416 && FileSize > 0)
	{
		_DBGAlert("FAsyncDownload::FHttpDownloadTP::ProcessDownload: Server status code: %d. Download complete\n", dwStatusCode); 
		return S_OK; 
	}
//.........这里部分代码省略.........
开发者ID:codeboost,项目名称:libertv,代码行数:101,代码来源:FAsyncHttpDownload.cpp

示例6: NewURL

int CHttpRequest::GetHTTP10(CUrl& iUrl, const CString& iE, inetSocket& Sock){
  /*
    attempt a retrieval of HTTP/1.0
    */  
  CString Request;
  if (ProxyURL.StrLength() && Proxy.isValid()) {
    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 += " HTTP/1.0"; Request+=iE;    
  } else {
    if (RLimit) Request += "GET "; else Request+="HEAD ";
    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;
#ifdef _U_DEBUG
  cout << "# HTTP Request: =====" << endl;
  cout << Request;
  cout << "=====================" << endl;
#endif
  /*
    issue request
    */
  CString RLoc;
  if (!Send(Sock, Request)) return 0;    
  ProcessHeader(Sock);
  ProcessData(Sock);
  switch(RStatusValue) {
  case 200: return 1;    
  case 301:
  case 302:
  case 303:
  case 307:  
    if (!FollowRedirections) return RStatusValue;
    RLoc = RHeaderResponse.get_value("Location");
    if (RLoc.StrLength()) {      
      /*
	HTTP 1.1 - Temporary Redirect is 302 and 307
	RedirectVector is relevant for final URL address
	that could be retrieved
	*/
      if (!RedirectVector.Contains(RLoc)) {
	RedirectVector+=RLoc; 
	CUrl NewURL(RLoc);      
	if (!Proxy.isValid()) {
	  inetSocket Sock2(NewURL.GetPortValue(), NewURL.GetHost());
	  return GetHTTP10(NewURL, iE, Sock2);
	} else {
	  Sock.Reopen();
	  return GetHTTP10(NewURL, iE, Sock);
	}      
      }
    }  
    return RStatusValue;
  case 305: /* use proxy */    
    RLoc = RHeaderResponse.get_value("Location");
    if (RLoc.StrLength()) {
      CUrl ProxyURL(RLoc);
      if (ProxyURL.isValid()) {
	inetSocket ProxySock(ProxyURL.GetPortValue(), ProxyURL.GetHost());
	if (wsLastError.StrLength()) return RStatusValue;	
	return GetHTTP10(iUrl, iE, ProxySock);
      }
    }
    return RStatusValue;  
  default: return RStatusValue;   
  }
}
开发者ID:dblock,项目名称:agnes,代码行数:79,代码来源:chttprequest.cpp


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