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