예제 #1
0
boost::optional<std::string> RESTRequest::getCookie(const std::string& key) {
	if (!cookies_) {
		boost::optional<std::string> cookieHeader = getHeader("Cookie");
		if (cookieHeader) {
			cookies_ = getCookies(*cookieHeader);
		}
		else {
			cookies_ = std::map<std::string, std::string>();
		}
	}
	auto it = cookies_->find(key);
	boost::optional<std::string> cookie;
	if (it != cookies_->end()) {
		cookie = it->second;
	}
	return cookie;
}
String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const KURL&, const KURL& url)
{
    return getCookies(url, true);
}
String cookiesForDOM(const NetworkStorageSession&, const KURL&, const KURL& url)
{
    // 'HttpOnly' cookies should no be accessible from scripts, so we filter them out here.
    return getCookies(url, false);
}
예제 #4
-1
void
cgicc::HTTPContentHeader::render(std::ostream& out)	const
{
    out << "Content-Type: " << getData() << std::endl;

    std::vector<HTTPCookie>::const_iterator iter;
    for(iter = getCookies().begin(); iter != getCookies().end(); ++iter)
        out << *iter << std::endl;

    out << std::endl;
}
예제 #5
-1
OnetAvatar::OnetAvatar() : QNetworkAccessManager(), basicRequest(QUrl(AVATAR_API))
{
    // Connection to the normal replyFinished function
    connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));

    getCookies();
}
String GoogleAnalyticsUrlStrategy::build( IFocusPoint* focusPoint )
{
	String builder( TRACKING_URL );
	builder += IGoogleAnalyticsParameters::URL_PARAM_DELIMITER;
	appendParameter( IGoogleAnalyticsParameters::PARAM_TRACKING_CODE_VERSION,
		IGoogleAnalyticsParameters::VALUE_TRACKING_CODE_VERSION, builder) ;
	appendParameter( IGoogleAnalyticsParameters::PARAM_UNIQUE_TRACKING_NUMBER, getRandomNumber(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_HOST_NAME, m_pGoogleParameters->getHostname(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_LANGUAGE_ENCODING,
		IGoogleAnalyticsParameters::VALUE_ENCODING_UTF8, builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_SCREEN_RESOLUTION, m_pGoogleParameters->getScreenResolution(),
		builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_SCREEN_COLOR_DEPTH, m_pGoogleParameters->getScreenColorDepth(),
		builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_BROWSER_LANGUAGE, m_pGoogleParameters->getBrowserLanguage(),
		builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_PAGE_TITLE, focusPoint->getTitle(), builder );
	//appendParameter( IGoogleAnalyticsParameters::PARAM_HID, getRandomNumber(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_FLASH_VERSION, m_pGoogleParameters->getFlashVersion(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_REFERRAL, m_pGoogleParameters->getReferral(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_PAGE_REQUEST, focusPoint->getURI(), builder );

	appendParameter( IGoogleAnalyticsParameters::PARAM_ACCOUNT_NAME, m_pGoogleParameters->getAccountName(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_COOKIES, getCookies(), builder );
	appendParameter( IGoogleAnalyticsParameters::PARAM_GAQ, _T("1"), false, builder );

	// update visit timestamps and count
	m_pGoogleParameters->visit();

	return builder;
}
예제 #7
-1
void 
cgicc::HTTPResponseHeader::render(std::ostream& out)	const
{
  std::vector<std::string>::const_iterator iter;
  std::vector<HTTPCookie>::const_iterator cookie_iter; 
  
  out << fHTTPVersion << ' ' << fStatusCode << ' ' << fReasonPhrase 
      << std::endl;
  
  for(iter = fHeaders.begin(); iter != fHeaders.end(); ++iter)
    out << *iter << std::endl;
  
  for(cookie_iter = getCookies().begin(); 
      cookie_iter != getCookies().end(); 
      ++cookie_iter)
    out << *cookie_iter << std::endl;
  
  out << std::endl;
}
예제 #8
-1
void RemoteJobManager::initHTTPRequest(Poco::Net::HTTPRequest &req,
                                       const std::string &method,
                                       std::string extraPath,
                                       std::string queryString) {
  // Set up the session object
  if (m_session) {
    delete m_session;
    m_session = nullptr;
  }

  if (Poco::URI(m_serviceBaseUrl).getScheme() == "https") {
    // Create an HTTPS session
    // TODO: Notice that we've set the context to VERIFY_NONE. I think that
    // means we're not checking the SSL certificate that the server
    // sends to us. That's BAD!!
    Poco::Net::Context::Ptr context =
        new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "", "", "",
                               Poco::Net::Context::VERIFY_NONE, 9, false,
                               "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
    m_session = new Poco::Net::HTTPSClientSession(
        Poco::URI(m_serviceBaseUrl).getHost(),
        Poco::URI(m_serviceBaseUrl).getPort(), context);
  } else {
    // Create a regular HTTP client session.  (NOTE: Using unencrypted HTTP is a
    // really bad idea! We'll be sending passwords in the clear!)
    m_session =
        new Poco::Net::HTTPClientSession(Poco::URI(m_serviceBaseUrl).getHost(),
                                         Poco::URI(m_serviceBaseUrl).getPort());
  }

  Poco::URI uri(m_serviceBaseUrl);
  std::string path = uri.getPath();
  // Path should be something like "/mws/rest", append extraPath to it.
  path += extraPath;

  uri.setPath(path);
  if (method == Poco::Net::HTTPRequest::HTTP_GET && !queryString.empty()) {
    uri.setQuery(queryString);
  }

  req.setVersion(Poco::Net::HTTPRequest::HTTP_1_1);
  req.setMethod(method);
  req.setURI(uri.toString());

  // Attach any cookies we've got from previous responses
  req.setCookies(getCookies());
}