HTTPSClient.cpp 758 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <algorithm>
  2. #include "HTTPSClient.h"
  3. // This may not be the order you expect, as shorter strings always compare less,
  4. // but it's sufficient for our map
  5. bool HTTPSClient::ci_string_less::operator()(const std::string &lhs, const std::string &rhs) const
  6. {
  7. const size_t lhs_size = lhs.size();
  8. const size_t rhs_size = rhs.size();
  9. const size_t steps = std::min(lhs_size, rhs_size);
  10. if (lhs_size < rhs_size)
  11. return true;
  12. else if (lhs_size > rhs_size)
  13. return false;
  14. for (size_t i = 0; i < steps; ++i)
  15. {
  16. char l = std::tolower(lhs[i]);
  17. char r = std::tolower(rhs[i]);
  18. if (l < r)
  19. return true;
  20. else if (l > r)
  21. return false;
  22. }
  23. return false;
  24. }
  25. HTTPSClient::Request::Request(const std::string &url)
  26. : url(url)
  27. , method(GET)
  28. {
  29. }