TestUtil.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "common.h"
  2. #include <string>
  3. #include "SharedHandle.h"
  4. #include "Cookie.h"
  5. namespace aria2 {
  6. class MessageDigest;
  7. void createFile(const std::string& filename, size_t length);
  8. std::string readFile(const std::string& path);
  9. class CookieSorter {
  10. public:
  11. bool operator()(const Cookie& lhs, const Cookie& rhs) const
  12. {
  13. if(lhs.getDomain() == rhs.getDomain()) {
  14. return lhs.getName() < rhs.getName();
  15. } else {
  16. return lhs.getDomain() < rhs.getDomain();
  17. }
  18. }
  19. };
  20. Cookie createCookie
  21. (const std::string& name,
  22. const std::string& value,
  23. const std::string& domain,
  24. bool hostOnly,
  25. const std::string& path,
  26. bool secure);
  27. Cookie createCookie
  28. (const std::string& name,
  29. const std::string& value,
  30. time_t expiryTime,
  31. const std::string& domain,
  32. bool hostOnly,
  33. const std::string& path,
  34. bool secure);
  35. #ifdef ENABLE_MESSAGE_DIGEST
  36. // Returns hex digest of contents of file denoted by filename.
  37. std::string fileHexDigest
  38. (const SharedHandle<MessageDigest>& ctx, const std::string& filename);
  39. #endif // ENABLE_MESSAGE_DIGEST
  40. } // namespace aria2