aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/websocketpp/websocketpp-0.8.1/9ddb300d874a30db35e3ad58f188944bef0bf31b.patch
blob: 94bfeb2fd4375dea7ecea8391a164f7c018d0db6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
## Description: add some description
## Origin/Author: add some origin or author
## Bug: bug URL
From 9ddb300d874a30db35e3ad58f188944bef0bf31b Mon Sep 17 00:00:00 2001
From: Peter Thorson <git@zaphoyd.com>
Date: Sun, 11 Jun 2017 15:24:43 -0500
Subject: [PATCH] Update permessage-deflate support to reflect that zlib
 doesn't support a 256 bit window. Improve extension negotiation error
 checking and documentation. fixes #596 fixes #653

---
 changelog.md                                       |   8 ++
 test/extension/permessage_deflate.cpp              | 153 +++++++++++++++++----
 .../extensions/permessage_deflate/enabled.hpp      |  94 ++++++++++---
 websocketpp/impl/connection_impl.hpp               |  10 +-
 websocketpp/processors/hybi13.hpp                  |  28 +++-
 5 files changed, 247 insertions(+), 46 deletions(-)

diff --git a/changelog.md b/changelog.md
index bba753cb..de98edd2 100644
#--- a/changelog.md
#+++ b/changelog.md
#@@ -17,6 +17,14 @@ HEAD
# - Compatibility: Update `telemetry_client` to use a slightly more cross platform
#   method of sleeping. Should work on windows now. Thank you Meir Yanovich for
#   reporting.
#+- Compatibility: Updated permessage-deflate support to reflect that the zlib
#+  library does not actually support a sliding window size of 256 bits. 
#+  WebSocket++ will no longer negotiate 256 bit deflate windows. If the user
#+  of the library tries to request a 256 bit window a 512 bit window will be
#+  specified instead (This was the previous behavior). #596 #653 Thank you 
#+  Vinnie Falco and Gianfranco Costamagna for reporting.
#+- Compatibility: Better error handling and logging in cases where extension
#+  requests parse correctly but negotiation fails. 
# - Bug: Store loggers in shared pointers to avoid crashes related to connections
#   trying to write logs entries after their respective endpoint has been
#   deallocated. Thank you Thalhammer for reporting and Jupp Müller for the 
diff --git a/test/extension/permessage_deflate.cpp b/test/extension/permessage_deflate.cpp
index 4cd3e7b6..805afcc3 100644
--- a/test/extension/permessage_deflate.cpp
+++ b/test/extension/permessage_deflate.cpp
@@ -186,15 +186,22 @@ BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_invalid ) {
 
 BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_valid ) {
     ext_vars v;
+    
+    // confirm that a request for a value of 8 is interpreted as 9
     v.attr["server_max_window_bits"] = "8";
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=9");
 
+    v.attr["server_max_window_bits"] = "9";
     v.esp = v.exts.negotiate(v.attr);
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
-    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=8");
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=9");
 
-    v.attr["server_max_window_bits"] = "15";
 
+    v.attr["server_max_window_bits"] = "15";
     v.esp = v.exts.negotiate(v.attr);
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
@@ -213,7 +220,7 @@ BOOST_AUTO_TEST_CASE( invalid_set_server_max_window_bits ) {
 
 BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_decline ) {
     ext_vars v;
-    v.attr["server_max_window_bits"] = "8";
+    v.attr["server_max_window_bits"] = "9";
 
     v.ec = v.exts.set_server_max_window_bits(15,pmd_mode::decline);
     v.esp = v.exts.negotiate(v.attr);
@@ -223,7 +230,7 @@ BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_decline ) {
     BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
 }
 
-BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_accept ) {
+BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_accept_8 ) {
     ext_vars v;
     v.attr["server_max_window_bits"] = "8";
 
@@ -232,10 +239,22 @@ BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_accept ) {
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
-    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=8");
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=9");
 }
 
-BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_largest ) {
+BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_accept ) {
+    ext_vars v;
+    v.attr["server_max_window_bits"] = "9";
+
+    v.ec = v.exts.set_server_max_window_bits(15,pmd_mode::accept);
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=9");
+}
+
+BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_largest_8 ) {
     ext_vars v;
     v.attr["server_max_window_bits"] = "8";
 
@@ -244,10 +263,22 @@ BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_largest ) {
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
-    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=8");
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=9");
 }
 
-BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_smallest ) {
+BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_largest ) {
+    ext_vars v;
+    v.attr["server_max_window_bits"] = "9";
+
+    v.ec = v.exts.set_server_max_window_bits(15,pmd_mode::largest);
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=9");
+}
+
+BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_smallest_8 ) {
     ext_vars v;
     v.attr["server_max_window_bits"] = "8";
 
@@ -256,7 +287,19 @@ BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_smallest ) {
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
-    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=8");
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=9");
+}
+
+BOOST_AUTO_TEST_CASE( negotiate_server_max_window_bits_smallest ) {
+    ext_vars v;
+    v.attr["server_max_window_bits"] = "9";
+
+    v.ec = v.exts.set_server_max_window_bits(15,pmd_mode::smallest);
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; server_max_window_bits=9");
 }
 
 // Negotiate server_max_window_bits
@@ -292,7 +335,13 @@ BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_valid ) {
     v.esp = v.exts.negotiate(v.attr);
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
-    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=8");
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=9");
+
+    v.attr["client_max_window_bits"] = "9";
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=9");
 
     v.attr["client_max_window_bits"] = "15";
     v.esp = v.exts.negotiate(v.attr);
@@ -311,7 +360,7 @@ BOOST_AUTO_TEST_CASE( invalid_set_client_max_window_bits ) {
     BOOST_CHECK_EQUAL(v.ec,pmde::make_error_code(pmde::invalid_max_window_bits));
 }
 
-BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_decline ) {
+BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_decline_8 ) {
     ext_vars v;
     v.attr["client_max_window_bits"] = "8";
 
@@ -323,7 +372,19 @@ BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_decline ) {
     BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
 }
 
-BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_accept ) {
+BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_decline ) {
+    ext_vars v;
+    v.attr["client_max_window_bits"] = "9";
+
+    v.ec = v.exts.set_client_max_window_bits(9,pmd_mode::decline);
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate");
+}
+
+BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_accept_8 ) {
     ext_vars v;
     v.attr["client_max_window_bits"] = "8";
 
@@ -332,10 +393,22 @@ BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_accept ) {
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
-    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=8");
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=9");
 }
 
-BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_largest ) {
+BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_accept ) {
+    ext_vars v;
+    v.attr["client_max_window_bits"] = "9";
+
+    v.ec = v.exts.set_client_max_window_bits(15,pmd_mode::accept);
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=9");
+}
+
+BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_largest_8 ) {
     ext_vars v;
     v.attr["client_max_window_bits"] = "8";
 
@@ -344,10 +417,22 @@ BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_largest ) {
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
-    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=8");
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=9");
 }
 
-BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_smallest ) {
+BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_largest ) {
+    ext_vars v;
+    v.attr["client_max_window_bits"] = "9";
+
+    v.ec = v.exts.set_client_max_window_bits(15,pmd_mode::largest);
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=9");
+}
+
+BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_smallest_8 ) {
     ext_vars v;
     v.attr["client_max_window_bits"] = "8";
 
@@ -356,7 +441,19 @@ BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_smallest ) {
     BOOST_CHECK( v.exts.is_enabled() );
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
     BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
-    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=8");
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=9");
+}
+
+BOOST_AUTO_TEST_CASE( negotiate_client_max_window_bits_smallest ) {
+    ext_vars v;
+    v.attr["client_max_window_bits"] = "9";
+
+    v.ec = v.exts.set_client_max_window_bits(15,pmd_mode::smallest);
+    v.esp = v.exts.negotiate(v.attr);
+    BOOST_CHECK( v.exts.is_enabled() );
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.first, websocketpp::lib::error_code() );
+    BOOST_CHECK_EQUAL( v.esp.second, "permessage-deflate; client_max_window_bits=9");
 }
 
 
@@ -507,7 +604,8 @@ BOOST_AUTO_TEST_CASE( compress_data ) {
     std::string compress_out;
     std::string decompress_out;
 
-    v.exts.init(true);
+    v.ec = v.exts.init(true);
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
 
     v.ec = v.exts.compress(compress_in,compress_out);
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
@@ -520,7 +618,8 @@ BOOST_AUTO_TEST_CASE( compress_data ) {
 BOOST_AUTO_TEST_CASE( compress_data_multiple ) {
     ext_vars v;
 
-    v.exts.init(true);
+    v.ec = v.exts.init(true);
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
 
     for (int i = 0; i < 2; i++) {
         std::string compress_in = "Hello";
@@ -545,11 +644,12 @@ BOOST_AUTO_TEST_CASE( compress_data_large ) {
 
     websocketpp::http::attribute_list alist;
 
-    alist["server_max_window_bits"] = "8";
-    v.exts.set_server_max_window_bits(8,websocketpp::extensions::permessage_deflate::mode::smallest);
+    alist["server_max_window_bits"] = "9";
+    v.exts.set_server_max_window_bits(9,websocketpp::extensions::permessage_deflate::mode::smallest);
 
     v.exts.negotiate(alist);
-    v.exts.init(true);
+    v.ec = v.exts.init(true);
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
 
     v.ec = v.exts.compress(compress_in,compress_out);
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
@@ -573,7 +673,8 @@ BOOST_AUTO_TEST_CASE( compress_data_no_context_takeover ) {
     v.exts.enable_server_no_context_takeover();
 
     v.exts.negotiate(alist);
-    v.exts.init(true);
+    v.ec = v.exts.init(true);
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
 
     v.ec = v.exts.compress(compress_in,compress_out1);
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
@@ -609,7 +710,8 @@ BOOST_AUTO_TEST_CASE( compress_empty ) {
     std::string compress_out;
     std::string decompress_out;
 
-    v.exts.init(true);
+    v.ec = v.exts.init(true);
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
 
     v.ec = v.exts.compress(compress_in,compress_out);
     BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
@@ -640,7 +742,8 @@ BOOST_AUTO_TEST_CASE( decompress_data ) {
     std::string out;
     std::string reference = "Hello";
 
-    v.exts.init(true);
+    v.ec = v.exts.init(true);
+    BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
 
     v.ec = v.exts.decompress(in,11,out);
 
diff --git a/websocketpp/extensions/permessage_deflate/enabled.hpp b/websocketpp/extensions/permessage_deflate/enabled.hpp
index 1581f14c..f20a1b1d 100644
--- a/websocketpp/extensions/permessage_deflate/enabled.hpp
+++ b/websocketpp/extensions/permessage_deflate/enabled.hpp
@@ -46,7 +46,7 @@
 namespace websocketpp {
 namespace extensions {
 
-/// Implementation of the draft permessage-deflate WebSocket extension
+/// Implementation of RFC 7692, the permessage-deflate WebSocket extension
 /**
  * ### permessage-deflate interface
  *
@@ -174,18 +174,30 @@ namespace websocketpp {
 namespace extensions {
 namespace permessage_deflate {
 
-/// Default value for server_max_window_bits as defined by draft 17
+/// Default value for server_max_window_bits as defined by RFC 7692
 static uint8_t const default_server_max_window_bits = 15;
-/// Minimum value for server_max_window_bits as defined by draft 17
+/// Minimum value for server_max_window_bits as defined by RFC 7692
+/**
+ * NOTE: A value of 8 is not actually supported by zlib, the deflate
+ * library that WebSocket++ uses. To preserve backwards compatibility
+ * with RFC 7692 and previous versions of the library a value of 8
+ * is accepted by the library but will always be negotiated as 9.
+ */
 static uint8_t const min_server_max_window_bits = 8;
-/// Maximum value for server_max_window_bits as defined by draft 17
+/// Maximum value for server_max_window_bits as defined by RFC 7692
 static uint8_t const max_server_max_window_bits = 15;
 
-/// Default value for client_max_window_bits as defined by draft 17
+/// Default value for client_max_window_bits as defined by RFC 7692
 static uint8_t const default_client_max_window_bits = 15;
-/// Minimum value for client_max_window_bits as defined by draft 17
+/// Minimum value for client_max_window_bits as defined by RFC 7692
+/**
+ * NOTE: A value of 8 is not actually supported by zlib, the deflate
+ * library that WebSocket++ uses. To preserve backwards compatibility
+ * with RFC 7692 and previous versions of the library a value of 8
+ * is accepted by the library but will always be negotiated as 9.
+ */
 static uint8_t const min_client_max_window_bits = 8;
-/// Maximum value for client_max_window_bits as defined by draft 17
+/// Maximum value for client_max_window_bits as defined by RFC 7692
 static uint8_t const max_client_max_window_bits = 15;
 
 namespace mode {
@@ -372,7 +384,7 @@ class enabled {
     /**
      * The bits setting is the base 2 logarithm of the maximum window size that
      * the server must use to compress outgoing messages. The permitted range
-     * is 8 to 15 inclusive. 8 represents a 256 byte window and 15 a 32KiB
+     * is 9 to 15 inclusive. 9 represents a 512 byte window and 15 a 32KiB
      * window. The default setting is 15.
      *
      * Mode Options:
@@ -386,6 +398,14 @@ class enabled {
      * adjusted by the server. A server may unilaterally set this value without
      * client support.
      *
+     * NOTE: The permessage-deflate spec specifies that a value of 8 is allowed.
+     * Prior to version 0.8.0 a value of 8 was also allowed by this library.
+     * zlib, the deflate compression library that WebSocket++ uses has always
+     * silently adjusted a value of 8 to 9. In recent versions of zlib (1.2.9 
+     * and greater) a value of 8 is now explicitly rejected. WebSocket++ 0.8.0
+     * continues to perform the 8->9 conversion for backwards compatibility
+     * purposes but this should be considered deprecated functionality.
+     *
      * @param bits The size to request for the outgoing window size
      * @param mode The mode to use for negotiating this parameter
      * @return A status code
@@ -394,6 +414,12 @@ class enabled {
         if (bits < min_server_max_window_bits || bits > max_server_max_window_bits) {
             return error::make_error_code(error::invalid_max_window_bits);
         }
+
+        // See note in doc comment above about what is happening here
+        if (bits == 8) {
+            bits = 9;
+        }
+
         m_server_max_window_bits = bits;
         m_server_max_window_bits_mode = mode;
 
@@ -403,8 +429,8 @@ class enabled {
     /// Limit client LZ77 sliding window size
     /**
      * The bits setting is the base 2 logarithm of the window size that the
-     * client must use to compress outgoing messages. The permitted range is 8
-     * to 15 inclusive. 8 represents a 256 byte window and 15 a 32KiB window.
+     * client must use to compress outgoing messages. The permitted range is 9
+     * to 15 inclusive. 9 represents a 512 byte window and 15 a 32KiB window.
      * The default setting is 15.
      *
      * Mode Options:
@@ -417,6 +443,14 @@ class enabled {
      * outgoing window size unilaterally. A server may only limit the client's
      * window size if the remote client supports that feature.
      *
+     * NOTE: The permessage-deflate spec specifies that a value of 8 is allowed.
+     * Prior to version 0.8.0 a value of 8 was also allowed by this library.
+     * zlib, the deflate compression library that WebSocket++ uses has always
+     * silently adjusted a value of 8 to 9. In recent versions of zlib (1.2.9 
+     * and greater) a value of 8 is now explicitly rejected. WebSocket++ 0.8.0
+     * continues to perform the 8->9 conversion for backwards compatibility
+     * purposes but this should be considered deprecated functionality.
+     *
      * @param bits The size to request for the outgoing window size
      * @param mode The mode to use for negotiating this parameter
      * @return A status code
@@ -425,6 +459,12 @@ class enabled {
         if (bits < min_client_max_window_bits || bits > max_client_max_window_bits) {
             return error::make_error_code(error::invalid_max_window_bits);
         }
+
+        // See note in doc comment above about what is happening here
+        if (bits == 8) {
+            bits = 9;
+        }
+
         m_client_max_window_bits = bits;
         m_client_max_window_bits_mode = mode;
 
@@ -642,11 +682,17 @@ class enabled {
      * client requested that we use.
      *
      * options:
-     * - decline (refuse to use the attribute)
-     * - accept (use whatever the client says)
-     * - largest (use largest possible value)
+     * - decline (ignore value, offer our default instead)
+     * - accept (use the value requested by the client)
+     * - largest (use largest value acceptable to both)
      * - smallest (use smallest possible value)
      *
+     * NOTE: As a value of 8 is no longer explicitly supported by zlib but might
+     * be requested for negotiation by an older client/server, if the result of
+     * the negotiation would be to send a value of 8, a value of 9 is offered
+     * instead. This ensures that WebSocket++ will only ever negotiate connections
+     * with compression settings explicitly supported by zlib.
+     *
      * @param [in] value The value of the attribute from the offer
      * @param [out] ec A reference to the error code to return errors via
      */
@@ -678,6 +724,11 @@ class enabled {
                 ec = make_error_code(error::invalid_mode);
                 m_server_max_window_bits = default_server_max_window_bits;
         }
+
+        // See note in doc comment
+        if (m_server_max_window_bits == 8) {
+            m_server_max_window_bits = 9;
+        }
     }
 
     /// Negotiate client_max_window_bits attribute
@@ -687,11 +738,17 @@ class enabled {
      * negotiation mode.
      *
      * options:
-     * - decline (refuse to use the attribute)
-     * - accept (use whatever the client says)
-     * - largest (use largest possible value)
+     * - decline (ignore value, offer our default instead)
+     * - accept (use the value requested by the client)
+     * - largest (use largest value acceptable to both)
      * - smallest (use smallest possible value)
      *
+     * NOTE: As a value of 8 is no longer explicitly supported by zlib but might
+     * be requested for negotiation by an older client/server, if the result of
+     * the negotiation would be to send a value of 8, a value of 9 is offered
+     * instead. This ensures that WebSocket++ will only ever negotiate connections
+     * with compression settings explicitly supported by zlib.
+     *
      * @param [in] value The value of the attribute from the offer
      * @param [out] ec A reference to the error code to return errors via
      */
@@ -727,6 +784,11 @@ class enabled {
                 ec = make_error_code(error::invalid_mode);
                 m_client_max_window_bits = default_client_max_window_bits;
         }
+
+        // See note in doc comment
+        if (m_client_max_window_bits == 8) {
+            m_client_max_window_bits = 9;
+        }
     }
 
     bool m_enabled;
diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp
index 105911db..ae55c338 100644
--- a/websocketpp/impl/connection_impl.hpp
+++ b/websocketpp/impl/connection_impl.hpp
@@ -1222,12 +1222,18 @@ lib::error_code connection<config>::process_handshake_request() {
     std::pair<lib::error_code,std::string> neg_results;
     neg_results = m_processor->negotiate_extensions(m_request);
 
-    if (neg_results.first) {
+    if (neg_results.first == error::make_error_code(error::extension_parse_error)) {
         // There was a fatal error in extension parsing that should result in
         // a failed connection attempt.
-        m_alog.write(log::alevel::devel, "Bad request: " + neg_results.first.message());
+        m_alog.write(log::alevel::info, "Bad request: " + neg_results.first.message());
         m_response.set_status(http::status_code::bad_request);
         return neg_results.first;
+    } else if (neg_results.first) {
+        // There was a fatal error in extension processing that is probably our
+        // fault. Consider extension negotiation to have failed and continue as
+        // if extensions were not supported
+        m_alog.write(log::alevel::info, 
+            "Extension negotiation failed: " + neg_results.first.message());
     } else {
         // extension negotiation succeeded, set response header accordingly
         // we don't send an empty extensions header because it breaks many
diff --git a/websocketpp/processors/hybi13.hpp b/websocketpp/processors/hybi13.hpp
index 79486654..a95bc649 100644
--- a/websocketpp/processors/hybi13.hpp
+++ b/websocketpp/processors/hybi13.hpp
@@ -97,6 +97,11 @@ class hybi13 : public processor<config> {
     /**
      * This exists mostly because the code for requests and responses is
      * identical and I can't have virtual template methods.
+     *
+     * NOTE: this method makes assumptions that the permessage-deflate
+     * extension is the only one supported. If additional extensions are
+     * ever supported it should be reviewed carefully. Most cases where
+     * that assumption is made are explicitly noted.
      */
     template <typename header_type>
     err_str_pair negotiate_extensions_helper(header_type const & header) {
@@ -149,9 +154,26 @@ class hybi13 : public processor<config> {
                     } else {
                         // Note: this list will need commas if WebSocket++ ever
                         // supports more than one extension
-                        ret.second += neg_ret.second;
-                        m_permessage_deflate.init(base::m_server);
-                        continue;
+                        
+                        // Actually try to initialize the extension before we
+                        // deem negotiation complete
+                        ret.first = m_permessage_deflate.init(base::m_server);
+                        if (!ret.first) {
+
+                            // TODO: support multiple extensions.
+                            // right now, because there is only one extension 
+                            // supported, it failing to negotiate means we are
+                            // done with all negotiating. In the future if more
+                            // extensions are supported a better solution will
+                            // be needed here.
+                            break;
+                        } else {
+                            ret.second += neg_ret.second;
+
+                            // continue looking for more extensions
+                            continue;
+                        }
+                        
                     }
                 }
             }