TestUtil.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. std::string fromHex(const std::string& s);
  36. #ifdef ENABLE_MESSAGE_DIGEST
  37. // Returns hex digest of contents of file denoted by filename.
  38. std::string fileHexDigest
  39. (const SharedHandle<MessageDigest>& ctx, const std::string& filename);
  40. #endif // ENABLE_MESSAGE_DIGEST
  41. } // namespace aria2