Skip to content

Commit 9dc013a

Browse files
author
Peter Thorson
committed
Add an FAQ entry explaining how to use permessage-deflate in 0.6.0 and 0.7.0
1 parent 931ad40 commit 9dc013a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

docs/faq.dox

+45
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,51 @@ Whether an Asio endpoint uses TLS or not is determined by its config template pa
2020
The `<websocketpp/config/asio.hpp>` and `<websocketpp/config/asio_client.hpp>` headers will include both the TLS and non-TLS varients of their respective configs and require the presence of OpenSSL. The `<websocketpp/config/asio_no_tls.hpp>` and `<websocketpp/config/asio_no_tls_client.hpp>` headers will include only the non-TLS configs and do not require OpenSSL.
2121

2222

23+
## Compression
24+
25+
### How do I use permessage-deflate in version 0.6.0-permessagedeflate and 0.7.0?
26+
27+
These versions of the library require a custom config to use the permessage-deflate extension. Here is a minimal example of such a custom config. You can also integrate these lines into an existing custom config.
28+
29+
Note that in these versions there is no fine grained control over which connections are compressed or not. Clients will request compression with the default settings and use it if the server supports it. Servers will accept whatever parameters clients request.
30+
31+
Outgoing messages by default will be compressed if compression was auto-negotiated during the handshake. There is an option to force a specific message to be sent uncompressed even if compression was negotiated. This may be useful for sending data that you know to be compressed already (images, zip files, etc).
32+
33+
34+
__Server Example__
35+
```
36+
#include <websocketpp/extensions/permessage_deflate/enabled.hpp>
37+
38+
struct deflate_server_config : public websocketpp::config::asio {
39+
// ... additional custom config if you need it for other things
40+
41+
/// permessage_compress extension
42+
struct permessage_deflate_config {};
43+
44+
typedef websocketpp::extensions::permessage_deflate::enabled
45+
<permessage_deflate_config> permessage_deflate_type;
46+
};
47+
48+
typedef websocketpp::server<deflate_server_config> server_endpoint_type;
49+
```
50+
51+
__Client Example__
52+
```
53+
#include <websocketpp/extensions/permessage_deflate/enabled.hpp>
54+
55+
struct deflate_client_config : public websocketpp::config::asio_client {
56+
// ... additional custom config if you need it for other things
57+
58+
/// permessage_compress extension
59+
struct permessage_deflate_config {};
60+
61+
typedef websocketpp::extensions::permessage_deflate::enabled
62+
<permessage_deflate_config> permessage_deflate_type;
63+
};
64+
65+
typedef websocketpp::client<deflate_client_config> client_endpoint_type;
66+
```
67+
2368
## Security
2469

2570
### Is it possible to terminate a malicious connection quickly, without tying up resources performing clean close steps,

0 commit comments

Comments
 (0)