You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB

4 months ago
  1. /*
  2. * IXWebSocketPerMessageDeflateOptions.h
  3. * Author: Benjamin Sergeant
  4. * Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
  5. */
  6. #pragma once
  7. #include <string>
  8. namespace ix
  9. {
  10. class WebSocketPerMessageDeflateOptions
  11. {
  12. public:
  13. WebSocketPerMessageDeflateOptions(
  14. bool enabled = false,
  15. bool clientNoContextTakeover = false,
  16. bool serverNoContextTakeover = false,
  17. uint8_t clientMaxWindowBits = kDefaultClientMaxWindowBits,
  18. uint8_t serverMaxWindowBits = kDefaultServerMaxWindowBits);
  19. WebSocketPerMessageDeflateOptions(std::string extension);
  20. std::string generateHeader();
  21. bool enabled() const;
  22. bool getClientNoContextTakeover() const;
  23. bool getServerNoContextTakeover() const;
  24. uint8_t getServerMaxWindowBits() const;
  25. uint8_t getClientMaxWindowBits() const;
  26. static bool startsWith(const std::string& str, const std::string& start);
  27. static std::string removeSpaces(const std::string& str);
  28. static uint8_t const kDefaultClientMaxWindowBits;
  29. static uint8_t const kDefaultServerMaxWindowBits;
  30. private:
  31. bool _enabled;
  32. bool _clientNoContextTakeover;
  33. bool _serverNoContextTakeover;
  34. uint8_t _clientMaxWindowBits;
  35. uint8_t _serverMaxWindowBits;
  36. void sanitizeClientMaxWindowBits();
  37. };
  38. } // namespace ix