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; }
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; }