Ejemplo n.º 1
0
bool RequestParser::parseCrazyWebSocketKey(const buffer_string& k,
					   ::uint32_t& result)
{
  std::string key = k.str();

  std::string number;
  int spaces = 0;

  for (unsigned i = 0; i < key.length(); ++i)
    if (key[i] >= '0' && key[i] <= '9')
      number += key[i];
    else if (key[i] == ' ')
      ++spaces;

  ::uint64_t n = boost::lexical_cast< ::uint64_t >(number);

  if (!spaces)
    return false;
  
  if (n % spaces == 0) {
    result = n / spaces;
    return true;
  } else
    return false;
}
Ejemplo n.º 2
0
bool buffer_string::operator==(const buffer_string& other) const
{
  if (next || other.next)
    return str() == other.str();
  else
    if (data && other.data)
      return strcmp(data, other.data) == 0;
    else
      return data == other.data;
}