HTTPSClient.cpp 776 B

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