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


C++ HTTPRequest类代码示例

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


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

示例1: QString

	bt::HTTPRequest* UPnPRouter::sendSoapQuery(const QString & query,const QString & soapact,const QString & controlurl,bool at_exit)
	{
		// if port is not set, 0 will be returned 
		// thanks to Diego R. Brogna for spotting this bug
		if (location.port()==0)
			location.setPort(80);
		
		QString http_hdr = QString(
				"POST %1 HTTP/1.1\r\n"
				"HOST: %2:%3\r\n"
				"Content-length: $CONTENT_LENGTH\r\n"
				"Content-Type: text/xml\r\n"
				"SOAPAction: \"%4\"\r\n"
				"\r\n").arg(controlurl).arg(location.host()).arg(location.port()).arg(soapact);

		
		HTTPRequest* r = new HTTPRequest(http_hdr,query,location.host(),location.port(),verbose);
		connect(r,SIGNAL(replyError(bt::HTTPRequest* ,const QString& )),
				this,SLOT(onReplyError(bt::HTTPRequest* ,const QString& )));
		connect(r,SIGNAL(replyOK(bt::HTTPRequest* ,const QString& )),
				this,SLOT(onReplyOK(bt::HTTPRequest* ,const QString& )));
		connect(r,SIGNAL(error(bt::HTTPRequest*, bool )),
				this,SLOT(onError(bt::HTTPRequest*, bool )));
		r->start();
		if (!at_exit)
			active_reqs.append(r);
		return r;
	}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: HttpRequestHandle

bool PluginLocate::HttpRequestHandle(HTTPRequest & request)
{
	QString uri = request.GetURI();
	if (uri.startsWith("/vl/locate.jsp"))
	{
		QString serialnumber = request.GetArg("sn").remove(':');
		
		LogInfo(QString("Requesting LOCATE for tag %1").arg(serialnumber));
		
		if(GlobalSettings::Get("Config/StandAlone", true) == false)
		{
			// Forward request to Violet
			QByteArray violetAnswer = request.ForwardTo(GlobalSettings::GetString("DefaultVioletServers/BootServer"));

			// Analyse the answer to see if servers has changed
			QList<QByteArray> lines = violetAnswer.split('\n');
			foreach(QByteArray line, lines)
			{
				if (line.startsWith("ping")) 
				{}
				else if (line.startsWith("broad"))
				{}
				else if (line.startsWith("xmpp_domain"))
				{}
				else
					if (line.size() != 0)
						LogError(QString("Unknown locate server : ") + line);
			}
		}
开发者ID:Laurent207,项目名称:OpenJabNab,代码行数:29,代码来源:plugin_locate.cpp

示例3: OnEvent

	void OnEvent(Event* event)
	{
		std::stringstream data("");

		if (event->GetEventID() == "httpd_url")
		{
			HTTPRequest* http = (HTTPRequest*)event->GetData();

			if (http->GetURI() == "/jsonrpc" && http->GetType() == "POST")
			{
				try
				{
					std::string response_text;
					json::rpc::process (http, response_text, http->GetPostData().c_str());
					data << response_text;
				}
				catch (std::runtime_error &)
				{
					data << "{ \"result\": \"JSON Fault\", \"error\": \"Invalid RPC call\", \"id\": 1}";
				}

				/* Send the document back to m_httpd */
				HTTPDocument response(http->sock, &data, 200, "X-Powered-By: m_rpc_json.so\r\n"
									      "Content-Type: application/json; charset=iso-8859-1\r\n");
				Request req((char*)&response, (Module*)this, event->GetSource());
				req.Send();
			}
		}
	}
开发者ID:TuSuNaMi,项目名称:ircd-sakura,代码行数:29,代码来源:m_rpc_json.cpp

示例4: OnEvent

    void OnEvent(Event& event)
    {
        std::stringstream data("");

        if (event.id == "httpd_url")
        {
            ServerInstance->Logs->Log("m_http_stats", LOG_DEBUG,"Handling httpd event");
            HTTPRequest* http = (HTTPRequest*)&event;

            if ((http->GetURI() == "/config") || (http->GetURI() == "/config/"))
            {
                data << "<html><head><title>InspIRCd Configuration</title></head><body>";
                data << "<h1>InspIRCd Configuration</h1><p>";

                for (ConfigDataHash::iterator x = ServerInstance->Config->config_data.begin(); x != ServerInstance->Config->config_data.end(); ++x)
                {
                    data << "&lt;" << x->first << " ";
                    ConfigTag* tag = x->second;
                    for (std::vector<KeyVal>::const_iterator j = tag->getItems().begin(); j != tag->getItems().end(); j++)
                    {
                        data << Sanitize(j->first) << "=&quot;" << Sanitize(j->second) << "&quot; ";
                    }
                    data << "&gt;<br>";
                }

                data << "</body></html>";
                /* Send the document back to m_httpd */
                HTTPDocumentResponse response(this, *http, &data, 200);
                response.headers.SetHeader("X-Powered-By", "m_httpd_config.so");
                response.headers.SetHeader("Content-Type", "text/html");
                response.Send();
            }
        }
    }
开发者ID:bandicot,项目名称:inspircd,代码行数:34,代码来源:m_httpd_config.cpp

示例5: authInfo

void HTTPCredentialsTest::testAuthenticationParams()
{
	const std::string authInfo("nonce=\"212573bb90170538efad012978ab811f%lu\", realm=\"TestDigest\", response=\"40e4889cfbd0e561f71e3107a2863bc4\", uri=\"/digest/\", username=\"user\"");
	HTTPAuthenticationParams params(authInfo);
	
	assert (params["nonce"] == "212573bb90170538efad012978ab811f%lu");
	assert (params["realm"] == "TestDigest");
	assert (params["response"] == "40e4889cfbd0e561f71e3107a2863bc4");
	assert (params["uri"] == "/digest/");
	assert (params["username"] == "user");
	assert (params.size() == 5);
	assert (params.toString() == authInfo);
	
	params.clear();
	HTTPRequest request;
	request.set("Authorization", "Digest " + authInfo);
	params.fromRequest(request);

	assert (params["nonce"] == "212573bb90170538efad012978ab811f%lu");
	assert (params["realm"] == "TestDigest");
	assert (params["response"] == "40e4889cfbd0e561f71e3107a2863bc4");
	assert (params["uri"] == "/digest/");
	assert (params["username"] == "user");
	assert (params.size() == 5);

	params.clear();
	HTTPResponse response;
	response.set("WWW-Authenticate", "Digest realm=\"TestDigest\", nonce=\"212573bb90170538efad012978ab811f%lu\"");	
	params.fromResponse(response);
	
	assert (params["realm"] == "TestDigest");
	assert (params["nonce"] == "212573bb90170538efad012978ab811f%lu");
	assert (params.size() == 2);
}
开发者ID:9drops,项目名称:poco,代码行数:34,代码来源:HTTPCredentialsTest.cpp

示例6: trackEvent

void StartupCall::trackEvent(const char *eventName)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
    const char *platform = "win";
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    const char *platform = "mac";
#else
    const char *platform = "UNKNOWN";
#endif
    
    HTTPRequest *request = HTTPRequest::createWithUrl(NULL,
                                                      "http://www.google-analytics.com/collect",
                                                      kCCHTTPRequestMethodPOST);
    request->addPOSTValue("v", "1");
    request->addPOSTValue("tid", "UA-84326395-1");
    request->addPOSTValue("cid", Native::getOpenUDID().c_str());
    request->addPOSTValue("t", "event");
    
    request->addPOSTValue("an", "player");
    request->addPOSTValue("av", cocos2dVersion());
    
    request->addPOSTValue("ec", platform);
    request->addPOSTValue("ea", eventName);
    
    request->start();
}
开发者ID:8liang,项目名称:Quick-Cocos2dx-Community,代码行数:26,代码来源:AppDelegate.cpp

示例7: testBadCredentials

void HTTPCredentialsTest::testBadCredentials()
{
	HTTPRequest request;
	
	std::string scheme;
	std::string info;
	try
	{
		request.getCredentials(scheme, info);
		fail("no credentials - must throw");
	}
	catch (NotAuthenticatedException&)
	{
	}
	
	request.setCredentials("Test", "SomeData");
	request.getCredentials(scheme, info);
	assert (scheme == "Test");
	assert (info == "SomeData");
	
	try
	{
		HTTPBasicCredentials cred(request);
		fail("bad scheme - must throw");
	}
	catch (NotAuthenticatedException&)
	{
	}
}
开发者ID:9drops,项目名称:poco,代码行数:29,代码来源:HTTPCredentialsTest.cpp

示例8: TEST

TEST(HTTPRequest, testInvalid3)
{
	std::string s("GET / HTTP/1.10");
	std::istringstream istr(s);
	HTTPRequest request;
    EXPECT_THROW(request.read(istr), MessageException);
}
开发者ID:ichenq,项目名称:PocoNet,代码行数:7,代码来源:HTTPRequestTest.cpp

示例9: tolua_cocos2dx_extra_luabinding_HTTPRequest_start00

static int tolua_cocos2dx_extra_luabinding_HTTPRequest_start00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HTTPRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HTTPRequest* self = (HTTPRequest*)  tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'start'", NULL);
#endif
  {
   bool tolua_ret = (bool)  self->start();
   tolua_pushboolean(tolua_S,(bool)tolua_ret);
  }
 }
 return 1;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'start'.",&tolua_err);
 return 0;
#endif
}
开发者ID:JackTongy,项目名称:trunk,代码行数:28,代码来源:cocos2dx_extra_luabinding.cpp

示例10: getIDs

void FetchFriends::run() 
{	
	replyMsg = ""; 

	success = twitObj->friendsIdsGet(twitObj->getTwitterUsername());
	if(!success) return;	

	twitObj->getLastWebResponse( replyMsg );
	std::vector<std::string> IDs = getIDs( replyMsg );
	
	success = twitObj->userLookup(IDs, true);
	if(!success) return;

	twitObj->getLastWebResponse( replyMsg );
	friends = getUsers( replyMsg );

	HTTPRequest req;
	req.init();
	req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
	
	for(int i=0 ; i<friends.size() ; i++) {
		std::string img;
		friendAvatars.push_back("");
		if(req.GET(friends[i].getProfileImgURL(), img)) friendAvatars[i] = img;
		else {
			LOG4CXX_INFO(logger, "Warning: Couldn't fetch Profile Image for " << user << "'s friend " << friends[i].getScreenName())
		}
	}
}
开发者ID:askovpen,项目名称:libtransport,代码行数:29,代码来源:FetchFriends.cpp

示例11: updateAuthParams

void HTTPDigestCredentials::updateAuthParams(const HTTPRequest& request)
{
	MD5Engine engine;
	const std::string& qop = _requestAuthParams.get(QOP_PARAM, DEFAULT_QOP);
	const std::string& realm = _requestAuthParams.getRealm();
	const std::string& nonce = _requestAuthParams.get(NONCE_PARAM);

	_requestAuthParams.set(URI_PARAM, request.getURI());

	if (qop.empty())
	{
		const std::string ha1 = digest(engine, _username, realm, _password);
		const std::string ha2 = digest(engine, request.getMethod(), request.getURI());

		_requestAuthParams.set(RESPONSE_PARAM, digest(engine, ha1, nonce, ha2));
	}
	else if (icompare(qop, AUTH_PARAM) == 0) 
	{
		const std::string& cnonce = _requestAuthParams.get(CNONCE_PARAM);

		const std::string ha1 = digest(engine, _username, realm, _password);
		const std::string ha2 = digest(engine, request.getMethod(), request.getURI());
		const std::string nc = formatNonceCounter(updateNonceCounter(nonce));

		_requestAuthParams.set(NC_PARAM, nc);
		_requestAuthParams.set(RESPONSE_PARAM, digest(engine, ha1, nonce, nc, cnonce, qop, ha2));
	}
}
开发者ID:9drops,项目名称:poco,代码行数:28,代码来源:HTTPDigestCredentials.cpp

示例12: load

void HTMLForm::load(const HTTPRequest& request, std::istream& requestBody, PartHandler& handler)
{
	if (request.getMethod() == HTTPRequest::HTTP_POST)
	{
		std::string mediaType;
		NameValueCollection params;
		MessageHeader::splitParameters(request.getContentType(), mediaType, params); 
		_encoding = mediaType;
		if (_encoding == ENCODING_MULTIPART)
		{
			_boundary = params["boundary"];
			readMultipart(requestBody, handler);
		}
		else
		{
			readUrl(requestBody);
		}
	}
	else
	{
		URI uri(request.getURI());
		std::istringstream istr(uri.getRawQuery());
		readUrl(istr);
	}
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例13: LogInfo

Node *Parser::parse(uHTTP::URL *url) {
  LogInfo("parse,TID(0x%04x): %s\n", GetCurrentThreadId(), url->getSting()); 
  HTTPRequest httpReq;
  HTTPResponse *httpRes = NULL;
  {
      FUNCTION_BLOCK_NAME_TRACE("post", 100);

      const char *host = url->getHost();
      int port = url->getPort();
      std::string target = url->getTarget();

      httpReq.setMethod(HTTP::GET);
      httpReq.setURI(target);
      httpRes = httpReq.post(host, port);
      if (httpRes->isSuccessful() == false){
          return NULL;
      }
  }

  Node* pNode = NULL;
  {
      FUNCTION_BLOCK_NAME_TRACE("ParseContent", 100);
     const char *contents = httpRes->getContent();
     pNode = parse(contents);
  }
  
  return pNode;
}
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:28,代码来源:Parser.cpp

示例14: tolua_cocos2dx_extra_luabinding_HTTPRequest_getErrorCode00

static int tolua_cocos2dx_extra_luabinding_HTTPRequest_getErrorCode00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HTTPRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HTTPRequest* self = (HTTPRequest*)  tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getErrorCode'", NULL);
#endif
  {
   int tolua_ret = (int)  self->getErrorCode();
   tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
  }
 }
 return 1;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'getErrorCode'.",&tolua_err);
 return 0;
#endif
}
开发者ID:JackTongy,项目名称:trunk,代码行数:28,代码来源:cocos2dx_extra_luabinding.cpp

示例15: tolua_cocos2dx_extra_luabinding_HTTPRequest_getResponseData00

static int tolua_cocos2dx_extra_luabinding_HTTPRequest_getResponseData00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HTTPRequest",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HTTPRequest* self = (HTTPRequest*)  tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getResponseDataLua'", NULL);
#endif
  {
     self->getResponseDataLua();

  }
 }
 return 1;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'getResponseData'.",&tolua_err);
 return 0;
#endif
}
开发者ID:JackTongy,项目名称:trunk,代码行数:28,代码来源:cocos2dx_extra_luabinding.cpp


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