Beispiel #1
0
	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;
	}
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);
			}
		}
Beispiel #3
0
	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();
			}
		}
	}
Beispiel #4
0
    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();
            }
        }
    }
Beispiel #5
0
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);
}
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();
}
Beispiel #7
0
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&)
	{
	}
}
Beispiel #8
0
TEST(HTTPRequest, testInvalid3)
{
	std::string s("GET / HTTP/1.10");
	std::istringstream istr(s);
	HTTPRequest request;
    EXPECT_THROW(request.read(istr), MessageException);
}
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
}
Beispiel #10
0
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())
		}
	}
}
Beispiel #11
0
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));
	}
}
Beispiel #12
0
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);
	}
}
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;
}
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
}
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
}
Beispiel #16
0
void httpreq_on_connect(uv_connect_t* con, int status) {
    if(status == -1) {
        printf("ERROR: httpreq_on_connect, cannot connect. @todo clean memory\n");
        return;
    }

    HTTPRequest* req = static_cast<HTTPRequest*>(con->data);
    int result = uv_read_start((uv_stream_t*)&req->tcp_req, httpreq_alloc, httpreq_on_read);
    if(result == -1) {
        printf("ERROR: uv_read_start() error: %s\n", uv_err_name(uv_last_error(req->loop)));
        return;
    }

    if(!req->is_secure) {
        req->sendData(&req->out_buffer[0], req->out_buffer.size());
    }
    else {
        req->ssl = SSL_new(req->ssl_ctx);
        req->ssl_buffer.addApplicationData(&req->out_buffer[0],req->out_buffer.size());
        SSL_set_connect_state(req->ssl);
        SSL_do_handshake(req->ssl);
        req->ssl_buffer.init(req->ssl, ssl_write_to_socket, req, ssl_read_decrypted, req);
        req->ssl_buffer.update();
    }
}
static int tolua_cocos2dx_extra_luabinding_HTTPRequest_setAcceptEncoding00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HTTPRequest",0,&tolua_err) ||
     !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HTTPRequest* self = (HTTPRequest*)  tolua_tousertype(tolua_S,1,0);
  int acceptEncoding = ((int)  tolua_tonumber(tolua_S,2,0));
#if COCOS2D_DEBUG >= 1
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setAcceptEncoding'", NULL);
#endif
  {
   self->setAcceptEncoding(acceptEncoding);
  }
 }
 return 0;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'setAcceptEncoding'.",&tolua_err);
 return 0;
#endif
}
static int tolua_cocos2dx_extra_luabinding_HTTPRequest_addFormContents00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HTTPRequest",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isstring(tolua_S,3,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,4,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HTTPRequest* self = (HTTPRequest*)  tolua_tousertype(tolua_S,1,0);
  const char* name = ((const char*)  tolua_tostring(tolua_S,2,0));
  const char* value = ((const char*)  tolua_tostring(tolua_S,3,0));
#if COCOS2D_DEBUG >= 1
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addFormContents'", NULL);
#endif
  {
   self->addFormContents(name,value);
  }
 }
 return 0;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'addFormContents'.",&tolua_err);
 return 0;
#endif
}
static int tolua_cocos2dx_extra_luabinding_HTTPRequest_getCookieString00(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 'getCookieString'", NULL);
#endif
  {
   string tolua_ret = (string)  self->getCookieString();
   tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
  }
 }
 return 1;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'getCookieString'.",&tolua_err);
 return 0;
#endif
}
static int tolua_cocos2dx_extra_luabinding_HTTPRequest_setPOSTData00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HTTPRequest",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HTTPRequest* self = (HTTPRequest*)  tolua_tousertype(tolua_S,1,0);
  const char* data = ((const char*)  tolua_tostring(tolua_S,2,0));
#if COCOS2D_DEBUG >= 1
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setPOSTData'", NULL);
#endif
  {
      size_t len;
      lua_tolstring(tolua_S, 2, &len);
      self->setPOSTData(data, len);
  }
 }
 return 0;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'setPOSTData'.",&tolua_err);
 return 0;
#endif
}
static int tolua_cocos2dx_extra_luabinding_HTTPRequest_addFormFile00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HTTPRequest",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isstring(tolua_S,3,0,&tolua_err) ||
     !tolua_isstring(tolua_S,4,1,&tolua_err) ||
     !tolua_isnoobj(tolua_S,5,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HTTPRequest* self = (HTTPRequest*)  tolua_tousertype(tolua_S,1,0);
  const char* name = ((const char*)  tolua_tostring(tolua_S,2,0));
  const char* filePath = ((const char*)  tolua_tostring(tolua_S,3,0));
  const char* fileType = ((const char*)  tolua_tostring(tolua_S,4,"application/octet-stream"));
#if COCOS2D_DEBUG >= 1
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'addFormFile'", NULL);
#endif
  {
   self->addFormFile(name,filePath,fileType);
  }
 }
 return 0;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'addFormFile'.",&tolua_err);
 return 0;
#endif
}
Beispiel #22
0
void SlackRTM::start() {
	std::string url = "https://slack.com/api/rtm.start?";
	url += "token=" + Util::urlencode(m_token);

	HTTPRequest *req = new HTTPRequest(THREAD_POOL(m_component), HTTPRequest::Get, url, boost::bind(&SlackRTM::handleRTMStart, this, _1, _2, _3, _4));
	req->execute();
}
static int tolua_cocos2dx_extra_luabinding_HTTPRequest_saveResponseData00(lua_State* tolua_S)
{
#if COCOS2D_DEBUG >= 1
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"HTTPRequest",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  HTTPRequest* self = (HTTPRequest*)  tolua_tousertype(tolua_S,1,0);
  const char* filename = ((const char*)  tolua_tostring(tolua_S,2,0));
#if COCOS2D_DEBUG >= 1
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'saveResponseData'", NULL);
#endif
  {
   int tolua_ret = (int)  self->saveResponseData(filename);
   tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
  }
 }
 return 1;
#if COCOS2D_DEBUG >= 1
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'saveResponseData'.",&tolua_err);
 return 0;
#endif
}
Beispiel #24
0
TEST(HTTPRequest, testInvalid1)
{
	std::string s(256, 'x');
	std::istringstream istr(s);
	HTTPRequest request;
    EXPECT_THROW(request.read(istr), MessageException);
}
Beispiel #25
0
// Sends a file to the server
void sendFile(HTTPClient* client, string filename) 
{
    HTTPRequest request;
    HTTPResponse response;

    // Send a HEAD request 
    request.method = "HEAD";
    request.path = "/" + filename;
    response = client->send(request);

    if (response.status == 200) {
        // The file exists. Compare MD5 checksums
        // TODO: Make a local MD5 checksums cache when this get's multithreaded.            
        if (WebUtil::MD5(filename) == response.getHeader("Content-MD5")) {
            return;        
        }
    }

    request.method = "PUT";
    request.path = "/" + filename;
    FILE* f = fopen(filename.c_str(),"r");
    if (f == NULL) {
        throw_exception("Couldn't read " + filename);        
    }
    request.setBody(f);

    request.addHeader("Content-type", WebUtil::pathToMimetype(filename));
    request.addHeader("Content-length", WebUtil::filesize(filename));
    response = client->send(request);
    fclose(f);
}
Beispiel #26
0
void ProfileImageRequest::run()
{
	HTTPRequest req;
	req.init();
	req.setProxy(ip, port, puser, ppasswd);
	success = req.GET(url, callbackdata);
	if(!success) error.assign(req.getCurlError());
}
Beispiel #27
0
void ssl_read_decrypted(const char* data, size_t len, void* user) {
    HTTPRequest* req = static_cast<HTTPRequest*>(user);
    std::copy(data, data+len, std::back_inserter(req->in_buffer));

    if(req->data_cb) {
        req->data_cb(data, len, req->data_user);
    }
}
Beispiel #28
0
CGIParser::CGIParser(const HTTPRequest& request, bool queryOnly)
{
    parse(request.getQueryString());
    if (!queryOnly && !strcmp(request.getMethod(),"POST")) {
        if (request.getContentType().find("application/x-www-form-urlencoded") != string::npos)
            parse(request.getRequestBody());
    }
}
void HTTPRequestTest::testWrite1()
{
	HTTPRequest request;
	std::ostringstream ostr;
	request.write(ostr);
	std::string s = ostr.str();
	assert (s == "GET / HTTP/1.0\r\n\r\n");
}
Beispiel #30
0
TEST(HTTPRequest, testWrite1)
{
	HTTPRequest request;
	std::ostringstream ostr;
	request.write(ostr);
	std::string s = ostr.str();
	EXPECT_TRUE (s == "GET / HTTP/1.0\r\n\r\n");
}