update api docs v2.0
[platform/upstream/libwebsockets.git] / changelog
1 Changelog
2 ---------
3
4 Fixes
5 -----
6
7 1) OpenSSL version tests not needed on LibreSSL and BoringSSL
8
9 2) Fix IPV6 build breakage
10
11 3) Some fixes for WinCE build
12
13 4) Additional canned mimetypes for mounts, the full list is
14
15         .ico    image/x-icon
16         .gif    image/gif
17         .js     text/javascript
18         .png    image/png
19         .jpg    image/jpeg
20         .gz     application/gzip
21         .JPG    image/jpeg
22         .html   text/html
23         .css    text/css
24         .txt    text/plain
25         .ttf    application/x-font-ttf
26         .woff   application/font-woff
27         .xml    application/xml
28
29 5) Allow per-vhost setting of which protocol should get used
30 when the protocol: header is not sent by the client
31
32
33 v2.0.0
34 ======
35
36 Summary
37 -------
38
39  - There are only api additions, the api is compatible with v1.7.x.  But
40    there is necessarily an soname bump to 8.
41  
42  - If you are using lws client, you mainly need to be aware the option
43    LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT is needed at context-creation time
44    if you will use SSL.
45    
46  - If you are using lws for serving, the above is also true but there are
47    many new features to simplify your code (and life).  There is a
48    summany online here
49    
50      https://libwebsockets.org/lws-2.0-new-features.html
51      
52    but basically the keywords are vhosts, mounts and plugins.  You can now
53    do the web serving part from lws without any user callback code at all.
54    See ./test-server/test-server-v2.0.c for an example, it has no user
55    code for ws either since it uses the protocol plugins... that one C file
56    is all that is needed to do the whole test server function.
57    
58    You now have the option to use a small generic ws-capable webserver
59    "lwsws" and write your ws part as a plugin.  That eliminates even
60    cut-and-pasting the test server code and offers more configurable
61    features like control over http cacheability in JSON.
62
63
64 Fixes
65 -----
66
67 These are already in 1.7.x series
68
69 1) MAJOR (Windows-only) fix assert firing
70
71 2) MAJOR http:/1.1 connections handled by  lws_return_http_status() did not
72 get sent a content-length resulting in the link hanging until the peer closed
73 it.  attack.sh updated to add a test for this.
74
75 3) MINOR An error about hdr struct in _lws_ws_related is corrected, it's not
76 known to affect anything until after it was fixed
77
78 4) MINOR During the close shutdown wait state introduced at v1.7, if something
79 requests callback on writeable for the socket it will busywait until the
80 socket closes
81
82 5) MAJOR Although the test server has done it for a few versions already, it
83 is now required for the user code to explicitly call
84
85         if (lws_http_transaction_completed(wsi))
86                 return -1;
87
88 when it finishes replying to a transaction in http.  Previously the library
89 did it for you, but that disallowed large, long transfers with multiple
90 trips around the event loop (and cgi...).
91
92 6) MAJOR connections on ah waiting list that closed did not get removed from
93 the waiting list...
94
95 7) MAJOR since we added the ability to hold an ah across http keepalive
96 transactions where more headers had already arrived, we broke the ability
97 to tell if more headers had arrived.  Result was if the browser didn't
98 close the keepalive, we retained ah for the lifetime of the keepalive,
99 using up the pool.
100
101 8) MAJOR windows-only-POLLHUP was not coming
102
103 9) Client should not send ext hdr if no exts
104
105 Changes
106 -------
107
108 1) MINOR test-server gained some new switches
109
110    -C <file>  use external SSL cert file
111    -K <file>  use external SSL key file
112    -A <file>  use external SSL CA cert file
113    
114    -u <uid>  set effective uid
115    -g <gid>  set effective gid
116
117 together you can use them like this to have the test-server work with the
118 usual purchased SSL certs from an official CA.
119
120    --ssl -C your.crt -K your.key -A your.cer -u 99 -g 99
121
122 2) MINOR the OpenSSL magic to setup ECDH cipher usage is implemented in the
123 library, and the ciphers restricted to use ECDH only.
124 Using this, the lws test server can score an A at SSLLABS test
125
126 3) MINOR STS (SSL always) header is added to the test server if you use --ssl.  With
127 that, we score A+ at SSLLABS test
128
129 4) MINOR daemonize function (disabled at cmake by default) is updated to work
130 with systemd
131
132 5) MINOR example systemd .service file now provided for test server
133 (not installed by default)
134
135 6) test server html is updated with tabs and a new live server monitoring
136 feature.  Input sanitization added to the js.
137
138 7) client connections attempted when no ah is free no longer fail, they are
139 just deferred until an ah becomes available.
140
141 8) The test client pays attention to if you give it an http:/ or https://
142 protocol string to its argument in URL format.  If so, it stays in http[s]
143 client mode and doesn't upgrade to ws[s], allowing you to do generic http client
144 operations.  Receiving transfer-encoding: chunked is supported.
145
146 9) If you enable -DLWS_WITH_HTTP_PROXY=1 at cmake, the test server has a
147 new URI path http://localhost:7681/proxytest If you visit here, a client
148 connection to http://example.com:80 is spawned, and the results piped on
149 to your original connection.
150
151 10) Also with LWS_WITH_HTTP_PROXY enabled at cmake, lws wants to link to an
152 additional library, "libhubbub".  This allows lws to do html rewriting on the
153 fly, adjusting proxied urls in a lightweight and fast way.
154
155 11) There's a new context creation flag LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT,
156 this is included automatically if you give any other SSL-related option flag.
157 If you give no SSL-related option flag, nor this one directly, then even
158 though SSL support may be compiled in, it is never initialized nor used for the
159 whole lifetime of the lws context.
160
161 Conversely in order to prepare the context to use SSL, even though, eg, you
162 are not listening on SSL but will use SSL client connections later, you must
163 give this flag explicitly to make sure SSL is initialized.
164
165
166 User API additions
167 ------------------
168
169 1) MINOR APIBREAK There's a new member in struct lws_context_creation_info, ecdh_curve,
170 which lets you set the name of the ECDH curve OpenSSL should use.  By
171 default (if you leave ecdh_curve NULL) it will use "prime256v1"
172
173 2) MINOR NEWAPI It was already possible to adopt a foreign socket that had not
174 been read from using lws_adopt_socket() since v1.7.  Now you can adopt a
175 partially-used socket if you don't need SSL, by passing it what you read
176 so it can drain that before reading from the socket.
177
178 LWS_VISIBLE LWS_EXTERN struct lws *
179 lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd,
180                 const char *readbuf, size_t len);
181
182 3) MINOR NEWAPI CGI type "network io" subprocess execution is now possible from
183 a simple api.
184
185 LWS_VISIBLE LWS_EXTERN int
186 lws_cgi(struct lws *wsi, char * const *exec_array,  int script_uri_path_len,
187         int timeout_secs);
188
189 LWS_VISIBLE LWS_EXTERN int
190 lws_cgi_kill(struct lws *wsi);
191
192 To use it, you must first set the cmake option
193
194 $ cmake .. -DLWS_WITH_CGI=1
195
196 See test-server-http.c and  test server path
197
198 http://localhost:7681/cgitest
199
200 stdin gets http body, you can test it with wget
201
202 $ echo hello > hello.txt
203 $ wget http://localhost:7681/cgitest --post-file=hello.txt -O- --quiet
204 lwstest script
205 read="hello"
206
207 The test script returns text/html table showing /proc/meminfo.  But the cgi
208 support is complete enough to run cgit cgi.
209
210 4) There is a helper api for forming logging timestamps
211
212 LWS_VISIBLE int
213 lwsl_timestamp(int level, char *p, int len)
214
215 this generates this kind of timestamp for use as logging preamble
216
217 lwsts[13116]: [2016/01/25 14:52:52:8386] NOTICE: Initial logging level 7
218
219 5) struct lws_client_connect_info has a new member
220
221  const char *method
222  
223 If it's NULL, then everything happens as before, lws_client_connect_via_info()
224 makes a ws or wss connection to the address given.
225
226 If you set method to a valid http method like "GET", though, then this method
227 is used and the connection remains in http[s], it's not upgraded to ws[s].
228
229 So with this, you can perform http[s] client operations as well as ws[s] ones.
230
231 There are 4 new related callbacks
232
233         LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP                    = 44,
234         LWS_CALLBACK_CLOSED_CLIENT_HTTP                         = 45,
235         LWS_CALLBACK_RECEIVE_CLIENT_HTTP                        = 46,
236         LWS_CALLBACK_COMPLETED_CLIENT_HTTP                      = 47,
237
238 6) struct lws_client_connect_info has a new member
239
240  const char *parent_wsi
241  
242 if non-NULL, the client wsi is set to be a child of parent_wsi.  This ensures
243 if parent_wsi closes, then the client child is closed just before.
244
245 7) If you're using SSL, there's a new context creation-time option flag
246 LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS.  If you give this, non-ssl
247 connections to the server listen port are accepted and receive a 301
248 redirect to / on the same host and port using https://
249
250 8) User code may set per-connection extension options now, using a new api
251 "lws_set_extension_option()".
252
253 This should be called from the ESTABLISHED callback like this
254
255  lws_set_extension_option(wsi, "permessage-deflate",
256                           "rx_buf_size", "12"); /* 1 << 12 */
257
258 If the extension is not active (missing or not negotiated for the
259 connection, or extensions are disabled on the library) the call is
260 just returns -1.  Otherwise the connection's extension has its
261 named option changed.
262
263 The extension may decide to alter or disallow the change, in the
264 example above permessage-deflate restricts the size of his rx
265 output buffer also considering the protocol's rx_buf_size member.
266
267
268 New application lwsws
269 ---------------------
270
271 A libwebsockets-based general webserver is built by default now, lwsws.
272
273 It's configured by JSON, by default in
274
275   /etc/lwsws/conf
276
277 which contains global lws context settings like this
278
279 {
280   "global": {
281    "uid": "99",
282    "gid": "99",
283    "interface": "eth0",
284    "count-threads": "1"
285  }
286 }
287
288   /etc/lwsws/conf.d/*
289
290 which contains zero or more files describing vhosts, like this
291
292 {
293  "vhosts": [
294   { "name": "warmcat.com",
295     "port": "443",
296     "host-ssl-key": "/etc/pki/tls/private/warmcat.com.key",
297     "host-ssl-cert": "/etc/pki/tls/certs/warmcat.com.crt",
298     "host-ssl-ca": "/etc/pki/tls/certs/warmcat.com.cer",
299     "mounts": [
300       { "/": [
301        { "home": "file:///var/www/warmcat.com" },
302        { "default": "index.html" }
303       ]
304      }
305     ]
306    }
307  ]
308 }
309
310
311
312 v1.7.0
313 ======
314
315 Extension Changes
316 -----------------
317
318 1) There is now a "permessage-deflate" / RFC7692 implementation.  It's very
319 similar to "deflate-frame" we have offered for a long while; deflate-frame is
320 now provided as an alias of permessage-deflate.
321
322 The main differences are that the new permessage-deflate implementation:
323
324  - properly performs streaming respecting input and output buffer limits.  The
325    old deflate-frame implementation could only work on complete deflate input
326    and produce complete inflate output for each frame.  The new implementation
327    only mallocs buffers at initialization.
328
329  - goes around the event loop after each input package is processed allowing
330    interleaved output processing.  The RX flow control api can be used to
331    force compressed input processing to match the rate of compressed output
332    processing (test--echo shows an example of how to do this).
333
334  - when being "deflate-frame" for compatibility he uses the same default zlib
335    settings as the old "deflate-frame", but instead of exponentially increasing
336    malloc allocations until the whole output will fit, he observes the default
337    input and output chunking buffer sizes of "permessage-deflate", that's
338    1024 in and 1024 out at a time.
339
340 2) deflate-stream has been disabled for many versions (for over a year) and is
341 now removed.  Browsers are now standardizing on "permessage-deflate" / RFC7692
342
343 3) struct lws_extension is simplified, and lws extensions now have a public
344 api (their callback) for use in user code to compose extensions and options
345 the user code wants.  lws_get_internal_exts() is deprecated but kept around
346 as a NOP.  The changes allow one extension implementation to go by different
347 names and allows the user client code to control option offers per-ext.
348
349 The test client and server are updated to use the new way.  If you use
350 the old way it should still work, but extensions will be disabled until you
351 update your code.
352
353 Extensions are now responsible for allocating and per-instance private struct
354 at instance construction time and freeing it when the instance is destroyed.
355 Not needing to know the size means the extension's struct can be opaque
356 to user code.
357
358
359 User api additions
360 ------------------
361
362 1) The info struct gained three new members
363
364  - max_http_header_data: 0 for default (1024) or set the maximum amount of known
365     http header payload that lws can deal with.  Payload in unknown http
366     headers is dropped silently.  If for some reason you need to send huge
367     cookies or other HTTP-level headers, you can now increase this at context-
368     creation time.
369
370  - max_http_header_pool: 0 for default (16) or set the maximum amount of http
371      headers that can be tracked by lws in this context.  For the server, if
372      the header pool is completely in use then accepts on the listen socket
373      are disabled until one becomes free.  For the client, if you simultaneously
374      have pending connects for more than this number of client connections,
375      additional connects will fail until some of the pending connections timeout
376      or complete.
377
378  - timeout_secs: 0 for default (currently 20s), or set the library's
379      network activity timeout to the given number of seconds
380
381 HTTP header processing in lws only exists until just after the first main
382 callback after the HTTP handshake... for ws connections that is ESTABLISHED and
383 for HTTP connections the HTTP callback.
384
385 So these settings are not related to the maximum number of simultaneous
386 connections, but the number of HTTP handshakes that may be expected or ongoing,
387 or have just completed, at one time.  The reason it's useful is it changes the
388 memory allocation for header processing to be one-time at context creation
389 instead of every time there is a new connection, and gives you control over
390 the peak allocation.
391
392 Setting max_http_header_pool to 1 is fine it will just queue incoming
393 connections before the accept as necessary, you can still have as many
394 simultaneous post-header connections as you like.  Since the http header
395 processing is completed and the allocation released after ESTABLISHED or the
396 HTTP callback, even with a pool of 1 many connections can be handled rapidly.
397
398 2) There is a new callback that allows the user code to get acccess to the
399 optional close code + aux data that may have been sent by the peer.
400
401 LWS_CALLBACK_WS_PEER_INITIATED_CLOSE:
402              The peer has sent an unsolicited Close WS packet.  @in and
403              @len are the optional close code (first 2 bytes, network
404              order) and the optional additional information which is not
405              defined in the standard, and may be a string or non-human-
406              readble data.
407              If you return 0 lws will echo the close and then close the
408              connection.  If you return nonzero lws will just close the
409              connection.
410
411 As usual not handling it does the right thing, if you're not interested in it
412 just ignore it.
413
414 The test server has "open and close" testing buttons at the bottom, if you
415 open and close that connection, on close it will send a close code 3000 decimal
416 and the string "Bye!" as the aux data.
417
418 The test server dumb-increment callback handles this callback reason and prints
419
420 lwsts[15714]: LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: len 6
421 lwsts[15714]:  0: 0x0B
422 lwsts[15714]:  1: 0xB8
423 lwsts[15714]:  2: 0x42
424 lwsts[15714]:  3: 0x79
425 lwsts[15714]:  4: 0x65
426 lwsts[15714]:  5: 0x21
427
428 3) There is a new API to allow the user code to control the content of the
429 close frame sent when about to return nonzero from the user callback to
430 indicate the connection should close.
431
432 /**
433  * lws_close_reason - Set reason and aux data to send with Close packet
434  *              If you are going to return nonzero from the callback
435  *              requesting the connection to close, you can optionally
436  *              call this to set the reason the peer will be told if
437  *              possible.
438  *
439  * @wsi:        The websocket connection to set the close reason on
440  * @status:     A valid close status from websocket standard
441  * @buf:        NULL or buffer containing up to 124 bytes of auxiliary data
442  * @len:        Length of data in @buf to send
443  */
444 LWS_VISIBLE LWS_EXTERN void
445 lws_close_reason(struct lws *wsi, enum lws_close_status status,
446                  unsigned char *buf, size_t len);
447
448 An extra button is added to the "open and close" test server page that requests
449 that the test server close the connection from his end.
450
451 The test server code will do so by
452
453                         lws_close_reason(wsi, LWS_CLOSE_STATUS_GOINGAWAY,
454                                          (unsigned char *)"seeya", 5);
455                         return -1;
456
457 The browser shows the close code and reason he received
458
459 websocket connection CLOSED, code: 1001, reason: seeya
460
461 4) There's a new context creation time option flag
462
463 LWS_SERVER_OPTION_VALIDATE_UTF8
464
465 if you set it in info->options, then TEXT and CLOSE frames will get checked to
466 confirm that they contain valid UTF-8.  If they don't, the connection will get
467 closed by lws.
468
469 5) ECDH Certs are now supported.  Enable the CMake option
470
471 cmake .. -DLWS_SSL_SERVER_WITH_ECDH_CERT=1 
472
473 **and** the info->options flag
474
475 LWS_SERVER_OPTION_SSL_ECDH
476
477 to build in support and select it at runtime.
478
479 6) There's a new api lws_parse_uri() that simplifies chopping up
480 https://xxx:yyy/zzz uris into parts nicely.  The test client now uses this
481 to allow proper uris as well as the old address style.
482
483 7) SMP support is integrated into LWS without any internal threading.  It's
484 very simple to use, libwebsockets-test-server-pthread shows how to do it,
485 use -j <n> argument there to control the number of service threads up to 32.
486
487 Two new members are added to the info struct
488
489         unsigned int count_threads;
490         unsigned int fd_limit_per_thread;
491         
492 leave them at the default 0 to get the normal singlethreaded service loop.
493
494 Set count_threads to n to tell lws you will have n simultaneous service threads
495 operating on the context.
496
497 There is still a single listen socket on one port, no matter how many
498 service threads.
499
500 When a connection is made, it is accepted by the service thread with the least
501 connections active to perform load balancing.
502
503 The user code is responsible for spawning n threads running the service loop
504 associated to a specific tsi (Thread Service Index, 0 .. n - 1).  See
505 the libwebsockets-test-server-pthread for how to do.
506
507 If you leave fd_limit_per_thread at 0, then the process limit of fds is shared
508 between the service threads; if you process was allowed 1024 fds overall then
509 each thread is limited to 1024 / n.
510
511 You can set fd_limit_per_thread to a nonzero number to control this manually, eg
512 the overall supported fd limit is less than the process allowance.
513
514 You can control the context basic data allocation for multithreading from Cmake
515 using -DLWS_MAX_SMP=, if not given it's set to 32.  The serv_buf allocation
516 for the threads (currently 4096) is made at runtime only for active threads.
517
518 Because lws will limit the requested number of actual threads supported
519 according to LWS_MAX_SMP, there is an api lws_get_count_threads(context) to
520 discover how many threads were actually allowed when the context was created.
521
522 It's required to implement locking in the user code in the same way that
523 libwebsockets-test-server-pthread does it, for the FD locking callbacks.
524
525 If LWS_MAX_SMP=1, then there is no code related to pthreads compiled in the
526 library.  If more than 1, a small amount of pthread mutex code is built into
527 the library.
528
529 8) New API
530
531 LWS_VISIBLE struct lws *
532 lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd)
533
534 allows foreign sockets accepted by non-lws code to be adopted by lws as if they
535 had just been accepted by lws' own listen socket.
536
537 9) X-Real-IP: header has been added as WSI_TOKEN_HTTP_X_REAL_IP
538
539 10) Libuv support is added, there are new related user apis
540
541 typedef void (lws_uv_signal_cb_t)(uv_loop_t *l, uv_signal_t *w, int revents);
542
543 LWS_VISIBLE LWS_EXTERN int
544 lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint,
545                   lws_uv_signal_cb_t *cb);
546
547 LWS_VISIBLE LWS_EXTERN int
548 lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi);
549
550 LWS_VISIBLE void
551 lws_uv_sigint_cb(uv_loop_t *loop, uv_signal_t *watcher, int revents);
552
553 and CMAKE option
554
555 LWS_WITH_LIBUV
556
557
558 User api changes
559 ----------------
560
561 1) LWS_SEND_BUFFER_POST_PADDING is now 0 and deprecated.  You can remove it; if
562 you still use it, obviously it does nothing.  Old binary code with nonzero
563 LWS_SEND_BUFFER_POST_PADDING is perfectly compatible, the old code just
564 allocated a buffer bigger than the library is going to use.
565
566 The example apps no longer use LWS_SEND_BUFFER_POST_PADDING.
567
568 The only path who made use of it was sending with LWS_WRITE_CLOSE --->
569
570 2) Because of lws_close_reason() formalizing handling close frames,
571 LWS_WRITE_CLOSE is removed from libwebsockets.h.  It was only of use to send
572 close frames...close frame content should be managed using lws_close_reason()
573 now.
574
575 3) We check for invalid CLOSE codes and complain about protocol violation in
576 our close code.  But it changes little since we were in the middle of closing
577 anyway.
578
579 4) zero-length RX frames and zero length TX frames are now allowed.
580
581 5) Pings and close used to be limited to 124 bytes, the correct limit is 125
582 so that is now also allowed.
583
584 6) LWS_PRE is provided as a synonym for LWS_SEND_BUFFER_PRE_PADDING, either is
585 valid to use now.
586
587 7) There's generic support for RFC7462 style extension options built into the
588 library now.  As a consequence, a field "options" is added to lws_extension.
589 It can be NULL if there are no options on the extension.  Extension internal
590 info is part of the public abi because extensions may be implemented outside
591 the library.
592
593 8) WSI_TOKEN_PROXY enum was accidentally defined to collide with another token
594 of value 73.  That's now corrected and WSI_TOKEN_PROXY moved to his own place at
595 77.
596
597 9) With the addition of libuv support, libev is not the only event loop
598 library in town and his api names must be elaborated with _ev_
599
600   Callback typedef: lws_signal_cb ---> lws_ev_signal_cb_t
601   lws_sigint_cfg --> lws_ev_sigint_cfg
602   lws_initloop --> lws_ev_initloop
603   lws_sigint_cb --> lws_ev_sigint_cb
604
605 10) Libev support is made compatible with multithreaded service,
606 lws_ev_initloop (was lws_initloop) gets an extra argument for the
607 thread service index (use 0 if you will just have 1 service thread).
608
609 LWS_VISIBLE LWS_EXTERN int
610 lws_ev_initloop(struct lws_context *context, ev_loop_t *loop, int tsi);
611
612
613 v1.6.0-chrome48-firefox42
614 =======================
615
616 Major API improvements
617 ----------------------
618
619 v1.6.0 has many cleanups and improvements in the API.  Although at first it
620 looks pretty drastic, user code will only need four actions to update it.
621
622  - Do the three search/replaces in your user code, /libwebsocket_/lws_/,
623    /libwebsockets_/lws_/, and /struct\ libwebsocket/struct\ lws/
624
625  - Remove the context parameter from your user callbacks
626
627  - Remove context as the first parameter from the "Eleven APIS" listed in the
628    User Api Changes section
629
630  - Add lws_get_context(wsi) as the first parameter on the "Three APIS" listed
631    in the User Api Changes section, and anywhere else you still need context
632
633 That's it... generally only a handful of the 14 affected APIs are actually in
634 use in your user code and you can find them quickest by compiling and visiting
635 the errors each in turn.  And the end results are much cleaner, more
636 predictable and maintainable.
637
638
639 User api additions
640 ------------------
641
642 1) lws now exposes his internal platform file abstraction in a way that can be
643 both used by user code to make it platform-agnostic, and be overridden or
644 subclassed by user code.  This allows things like handling the URI "directory
645 space" as a virtual filesystem that may or may not be backed by a regular
646 filesystem.  One example use is serving files from inside large compressed
647 archive storage without having to unpack anything except the file being
648 requested.
649
650 The test server shows how to use it, basically the platform-specific part of
651 lws prepares a file operations structure that lives in the lws context.
652
653 Helpers are provided to also leverage these platform-independent file handling
654 apis
655
656 static inline lws_filefd_type
657 lws_plat_file_open(struct lws *wsi, const char *filename,
658                    unsigned long *filelen, int flags)
659 static inline int
660 lws_plat_file_close(struct lws *wsi, lws_filefd_type fd)
661
662 static inline unsigned long
663 lws_plat_file_seek_cur(struct lws *wsi, lws_filefd_type fd, long offset)
664
665 static inline int
666 lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
667                    unsigned char *buf, unsigned long len)
668
669 static inline int
670 lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount,
671                     unsigned char *buf, unsigned long len)
672                     
673 The user code can also override or subclass the file operations, to either
674 wrap or replace them.  An example is shown in test server.
675
676 A wsi can be associated with the file activity, allowing per-connection
677 authentication and state to be used when interpreting the file request.
678
679 2) A new API void * lws_wsi_user(struct lws *wsi) lets you get the pointer to
680 the user data associated with the wsi, just from the wsi.
681
682 3) URI argument handling.  Libwebsockets parses and protects URI arguments
683 like test.html?arg1=1&arg2=2, it decodes %xx uriencoding format and reduces
684 path attacks like ../.../../etc/passwd so they cannot go behind the web
685 server's /.  There is a list of confirmed attacks we're proof against in
686 ./test-server/attack.sh.
687
688 There is a new API lws_hdr_copy_fragment that should be used now to access
689 the URI arguments (it returns the fragments length)
690
691                while (lws_hdr_copy_fragment(wsi, buf, sizeof(buf),
692                                             WSI_TOKEN_HTTP_URI_ARGS, n) > 0) {
693                        lwsl_info("URI Arg %d: %s\n", ++n, buf);
694                }
695
696 For the example above, calling with n=0 will return "arg1=1" and n=1 "arg2=2".
697 All legal uriencodings will have been reduced in those strings.
698
699 lws_hdr_copy_fragment() returns the length of the x=y fragment, so it's also
700 possible to deal with arguments containing %00.  If you don't care about that,
701 the returned string has '\0' appended to simplify processing.
702
703
704 User api changes
705 ----------------
706
707 1) Three APIS
708
709  - lws_callback_on_writable_all_protocol(const struct lws_protocols *protocol)
710  - lws_callback_all_protocol(const struct lws_protocols *protocol)
711  - lws_rx_flow_allow_all_protocol(lws_rx_flow_allow_all_protocol)
712
713 Now take an additional pointer to the lws_context in their first argument.
714
715 The reason for this change is struct lws_protocols has been changed to remove
716 members that lws used for private storage: so the protocols struct in now
717 truly const and may be reused serially or simultaneously by different contexts.
718
719 2) Eleven APIs
720
721 LWS_VISIBLE LWS_EXTERN int
722 lws_add_http_header_by_name(struct lws_context *context,
723                 struct lws *wsi,
724                 const unsigned char *name,
725                 const unsigned char *value,
726                 int length,
727                 unsigned char **p,
728                 unsigned char *end);
729 LWS_VISIBLE LWS_EXTERN int
730 lws_finalize_http_header(struct lws_context *context,
731              struct lws *wsi,
732              unsigned char **p,
733              unsigned char *end);
734 LWS_VISIBLE LWS_EXTERN int
735 lws_add_http_header_by_token(struct lws_context *context,
736                  struct lws *wsi,
737                  enum lws_token_indexes token,
738                  const unsigned char *value,
739                  int length,
740                  unsigned char **p,
741                  unsigned char *end);
742 LWS_VISIBLE LWS_EXTERN int
743 lws_add_http_header_content_length(struct lws_context *context,
744                    struct lws *wsi,
745                    unsigned long content_length,
746                    unsigned char **p,
747                    unsigned char *end);
748 LWS_VISIBLE LWS_EXTERN int
749 lws_add_http_header_status(struct lws_context *context, struct lws *wsi,
750                unsigned int code, unsigned char **p,
751                unsigned char *end);
752
753 LWS_VISIBLE LWS_EXTERN int
754 lws_serve_http_file(struct lws_context *context, struct lws *wsi,
755             const char *file, const char *content_type,
756             const char *other_headers, int other_headers_len);
757 LWS_VISIBLE LWS_EXTERN int
758 lws_serve_http_file_fragment(struct lws_context *context, struct lws *wsi);
759
760 LWS_VISIBLE LWS_EXTERN int
761 lws_return_http_status(struct lws_context *context, struct lws *wsi,
762                unsigned int code, const char *html_body);
763
764 LWS_VISIBLE LWS_EXTERN int
765 lws_callback_on_writable(const struct lws_context *context, struct lws *wsi);
766
767 LWS_VISIBLE LWS_EXTERN void
768 lws_get_peer_addresses(struct lws_context *context, struct lws *wsi,
769                lws_sockfd_type fd, char *name, int name_len,
770                char *rip, int rip_len);
771
772 LWS_VISIBLE LWS_EXTERN int
773 lws_read(struct lws_context *context, struct lws *wsi,
774      unsigned char *buf, size_t len); 
775
776 no longer require their initial struct lws_context * parameter.
777
778 3) Several older apis start with libwebsocket_ or libwebsockets_ while newer ones
779 all begin lws_.  These apis have been changed to all begin with lws_.
780
781 To convert, search-replace
782
783  - libwebsockets_/lws_
784  - libwebsocket_/lws_
785  - struct\ libwebsocket/struct\ lws
786  
787 4) context parameter removed from user callback.
788
789 Since almost all apis no longer need the context as a parameter, it's no longer
790 provided at the user callback directly.
791
792 However if you need it, for ALL callbacks wsi is valid and has a valid context
793 pointer you can recover using lws_get_context(wsi).
794
795
796 v1.5-chrome47-firefox41
797 =======================
798
799 User api changes
800 ----------------
801
802 LWS_CALLBACK_CLIENT_CONNECTION_ERROR may provide an error string if in is
803 non-NULL.  If so, the string has length len.
804
805 LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED is available to relax the requirement
806 for peer certs if you are using the option to require client certs.
807
808 LWS_WITHOUT_BUILTIN_SHA1 cmake option forces lws to use SHA1() defined
809 externally, eg, byOpenSSL, and disables build of libwebsockets_SHA1()
810
811
812 v1.4-chrome43-firefox36
813 =======================
814
815 User api additions
816 ------------------
817
818 There's a new member in the info struct used to control context creation,
819 ssl_private_key_password, which allows passing into lws the passphrase on
820 an SSL cetificate
821
822 There's a new member in struct protocols, id, which is ignored by lws but can
823 be used by the user code to mark the selected protocol by user-defined version
824 or capabliity flag information, for the case multiple versions of a protocol are
825 supported.
826
827 int lws_is_ssl(wsi) added to allow user code to know if the connection was made
828 over ssl or not.  If LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT is used, both
829 ssl and non-ssl connections are possible and may need to be treated differently
830 in the user code.
831
832 int lws_partial_buffered(wsi) added... should be checked after any
833 libwebsocket_write that will be followed by another libwebsocket_write inside
834 the same writeable callback.  If set, you can't do any more writes until the
835 writeable callback is called again.  If you only do one write per writeable callback,
836 you can ignore this.
837
838 HTTP2-related: HTTP2 changes how headers are handled, lws now has new version-
839 agnositic header creation APIs.  These do the right thing depending on each
840 connection's HTTP version without the user code having to know or care, except
841 to make sure to use the new APIs for headers (test-server is updated to use
842 them already, so look there for examples)
843
844 The APIs "render" the headers into a user-provided buffer and bump *p as it
845 is used.  If *p reaches end, then the APIs return nonzero for error.
846
847 LWS_VISIBLE LWS_EXTERN int
848 lws_add_http_header_status(struct libwebsocket_context *context,
849                             struct libwebsocket *wsi,
850                             unsigned int code,
851                             unsigned char **p,
852                             unsigned char *end);
853
854 Start a response header reporting status like 200, 500, etc
855
856 LWS_VISIBLE LWS_EXTERN int
857 lws_add_http_header_by_name(struct libwebsocket_context *context,
858                             struct libwebsocket *wsi,
859                             const unsigned char *name,
860                             const unsigned char *value,
861                             int length,
862                             unsigned char **p,
863                             unsigned char *end);
864
865 Add a header like name: value in HTTP1.x
866
867 LWS_VISIBLE LWS_EXTERN int 
868 lws_finalize_http_header(struct libwebsocket_context *context,
869                             struct libwebsocket *wsi,
870                             unsigned char **p,
871                             unsigned char *end);
872
873 Finish off the headers, like add the extra \r\n in HTTP1.x
874
875 LWS_VISIBLE LWS_EXTERN int
876 lws_add_http_header_by_token(struct libwebsocket_context *context,
877                             struct libwebsocket *wsi,
878                             enum lws_token_indexes token,
879                             const unsigned char *value,
880                             int length,
881                             unsigned char **p,
882                             unsigned char *end);
883
884 Add a header by using a lws token as the name part.  In HTTP2, this can be
885 compressed to one or two bytes.
886
887
888 User api removal
889 ----------------
890
891 protocols struct member no_buffer_all_partial_tx is removed.  Under some
892 conditions like rewriting extension such as compression in use, the built-in
893 partial send buffering is the only way to deal with the problem, so turning
894 it off is deprecated.
895
896
897 User api changes
898 ----------------
899
900 HTTP2-related: API libwebsockets_serve_http_file() takes an extra parameter at
901 the end now
902
903 int other_headers_len)
904
905 If you are providing other headers, they must be generated using the new
906 HTTP-version-agnostic APIs, and you must provide the length of them using this
907 additional parameter.
908
909 struct lws_context_creation_info now has an additional member
910 SSL_CTX *provided_client_ssl_ctx you may set to an externally-initialized
911 SSL_CTX managed outside lws.  Defaulting to zero keeps the existing behaviour of
912 lws managing the context, if you memset the struct to 0 or have as a filescope
913 initialized struct in bss, no need to change anything.
914
915
916 v1.3-chrome37-firefox30
917 =======================
918
919  .gitignore                                               |    1 -
920  CMakeLists.txt                                           |  447 +++--
921  README.build                                             |   35 +-
922  README.coding                                            |   14 +
923  changelog                                                |   66 +
924  cmake/LibwebsocketsConfig.cmake.in                       |   17 +
925  cmake/LibwebsocketsConfigVersion.cmake.in                |   11 +
926  config.h.cmake                                           |   18 +
927  cross-ming.cmake                                         |   31 +
928  cross-openwrt-makefile                                   |   91 +
929  lib/client-handshake.c                                   |  205 ++-
930  lib/client-parser.c                                      |   58 +-
931  lib/client.c                                             |  158 +-
932  lib/context.c                                            |  341 ++++
933  lib/extension-deflate-frame.c                            |    2 +-
934  lib/extension.c                                          |  178 ++
935  lib/handshake.c                                          |  287 +---
936  lib/lextable.h                                           |  338 ++++
937  lib/libev.c                                              |  175 ++
938  lib/libwebsockets.c                                      | 2089 +++--------------------
939  lib/libwebsockets.h                                      |  253 ++-
940  lib/lws-plat-unix.c                                      |  404 +++++
941  lib/lws-plat-win.c                                       |  358 ++++
942  lib/minilex.c                                            |  530 +++---
943  lib/output.c                                             |  445 ++---
944  lib/parsers.c                                            |  682 ++++----
945  lib/pollfd.c                                             |  239 +++
946  lib/private-libwebsockets.h                              |  501 +++++-
947  lib/server-handshake.c                                   |  274 +--
948  lib/server.c                                             |  858 ++++++++--
949  lib/service.c                                            |  517 ++++++
950  lib/sha-1.c                                              |   38 +-
951  lib/ssl-http2.c                                          |   78 +
952  lib/ssl.c                                                |  571 +++++++
953  test-server/attack.sh                                    |  101 +-
954  test-server/test-client.c                                |    9 +-
955  test-server/test-echo.c                                  |   17 +-
956  test-server/test-fraggle.c                               |    7 -
957  test-server/test-ping.c                                  |   12 +-
958  test-server/test-server.c                                |  330 ++--
959  test-server/test.html                                    |    4 +-
960  win32port/client/client.vcxproj                          |  259 ---
961  win32port/client/client.vcxproj.filters                  |   39 -
962  .../libwebsocketswin32.vcxproj.filters                   |   93 -
963  win32port/server/server.vcxproj                          |  276 ---
964  win32port/server/server.vcxproj.filters                  |   51 -
965  win32port/win32helpers/gettimeofday.h                    |   59 +-
966  win32port/win32helpers/netdb.h                           |    1 -
967  win32port/win32helpers/strings.h                         |    0
968  win32port/win32helpers/sys/time.h                        |    1 -
969  win32port/win32helpers/unistd.h                          |    0
970  win32port/win32helpers/websock-w32.c                     |  104 --
971  win32port/win32helpers/websock-w32.h                     |   62 -
972  win32port/win32port.sln                                  |  100 --
973  win32port/zlib/gzio.c                                    |    3 +-
974  55 files changed, 6779 insertions(+), 5059 deletions(-)
975
976
977 User api additions
978 ------------------
979
980 POST method is supported
981
982 The protocol 0 / HTTP callback can now get two new kinds of callback,
983 LWS_CALLBACK_HTTP_BODY (in and len are a chunk of the body of the HTTP request)
984 and LWS_CALLBACK_HTTP_BODY_COMPLETION (the expected amount of body has arrived
985 and been passed to the user code already).  These callbacks are used with the
986 post method (see the test server for details).
987
988 The period between the HTTP header completion and the completion of the body
989 processing is protected by a 5s timeout.
990
991 The chunks are stored in a malloc'd buffer of size protocols[0].rx_buffer_size.
992
993
994 New server option you can enable from user code
995 LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT allows non-SSL connections to
996 also be accepted on an SSL listening port.  It's disabled unless you enable
997 it explicitly.
998
999
1000 Two new callbacks are added in protocols[0] that are optional for allowing
1001 limited thread access to libwebsockets, LWS_CALLBACK_LOCK_POLL and
1002 LWS_CALLBACK_UNLOCK_POLL.
1003
1004 If you use them, they protect internal and external poll list changes, but if
1005 you want to use external thread access to libwebsocket_callback_on_writable()
1006 you have to implement your locking here even if you don't use external
1007 poll support.
1008
1009 If you will use another thread for this, take a lot of care about managing
1010 your list of live wsi by doing it from ESTABLISHED and CLOSED callbacks
1011 (with your own locking).
1012
1013 If you configure cmake with -DLWS_WITH_LIBEV=1 then the code allowing the libev
1014 eventloop instead of the default poll() one will also be compiled in.  But to
1015 use it, you must also set the LWS_SERVER_OPTION_LIBEV flag on the context
1016 creation info struct options member.
1017
1018 IPV6 is supported and enabled by default except for Windows, you can disable
1019 the support at build-time by giving -DLWS_IPV6=, and disable use of it even if
1020 compiled in by making sure the flag LWS_SERVER_OPTION_DISABLE_IPV6 is set on
1021 the context creation info struct options member.
1022
1023 You can give LWS_SERVER_OPTION_DISABLE_OS_CA_CERTS option flag to
1024 guarantee the OS CAs will not be used, even if that support was selected at
1025 build-time.
1026
1027 Optional "token limits" may be enforced by setting the member "token_limits"
1028 in struct lws_context_creation_info to point to a struct lws_token_limits.
1029 NULL means no token limits used for compatibility.
1030
1031
1032 User api changes
1033 ----------------
1034
1035 Extra optional argument to libwebsockets_serve_http_file() allows injecion
1036 of HTTP headers into the canned response.  Eg, cookies may be added like
1037 that without getting involved in having to send the header by hand.
1038
1039 A new info member http_proxy_address may be used at context creation time to
1040 set the http proxy.  If non-NULL, it overrides http_proxy environment var.
1041
1042 Cmake supports LWS_SSL_CLIENT_USE_OS_CA_CERTS defaulting to on, which gets
1043 the client to use the OS CA Roots.  If you're worried somebody with the
1044 ability to forge for force creation of a client cert from the root CA in
1045 your OS, you should disable this since your selfsigned $0 cert is a lot safer
1046 then...
1047
1048
1049 v1.23-chrome32-firefox24
1050 ========================
1051
1052  Android.mk                            |   29 +
1053  CMakeLists.txt                        |  573 ++++++++----
1054  COPYING                               |  503 -----------
1055  INSTALL                               |  365 --------
1056  Makefile.am                           |   13 -
1057  README.build                          |  371 ++------
1058  README.coding                         |   63 ++
1059  autogen.sh                            | 1578 ---------------------------------
1060  changelog                             |   69 ++
1061  cmake/FindGit.cmake                   |  163 ++++
1062  cmake/FindOpenSSLbins.cmake           |   15 +-
1063  cmake/UseRPMTools.cmake               |  176 ++++
1064  config.h.cmake                        |   25 +-
1065  configure.ac                          |  226 -----
1066  cross-arm-linux-gnueabihf.cmake       |   28 +
1067  lib/Makefile.am                       |   89 --
1068  lib/base64-decode.c                   |   98 +-
1069  lib/client-handshake.c                |  123 ++-
1070  lib/client-parser.c                   |   19 +-
1071  lib/client.c                          |  145 ++-
1072  lib/daemonize.c                       |    4 +-
1073  lib/extension.c                       |    2 +-
1074  lib/getifaddrs.h                      |    4 +-
1075  lib/handshake.c                       |   76 +-
1076  lib/libwebsockets.c                   |  491 ++++++----
1077  lib/libwebsockets.h                   |  164 ++--
1078  lib/output.c                          |  214 ++++-
1079  lib/parsers.c                         |  102 +--
1080  lib/private-libwebsockets.h           |   66 +-
1081  lib/server-handshake.c                |    5 +-
1082  lib/server.c                          |   29 +-
1083  lib/sha-1.c                           |    2 +-
1084  libwebsockets-api-doc.html            |  249 +++---
1085  libwebsockets.pc.in                   |   11 -
1086  libwebsockets.spec                    |   14 +-
1087  m4/ignore-me                          |    2 -
1088  scripts/FindLibWebSockets.cmake       |   33 +
1089  scripts/kernel-doc                    |    1 +
1090  test-server/Makefile.am               |  131 ---
1091  test-server/leaf.jpg                  |  Bin 0 -> 2477518 bytes
1092  test-server/test-client.c             |   78 +-
1093  test-server/test-echo.c               |   33 +-
1094  test-server/test-fraggle.c            |   26 +-
1095  test-server/test-ping.c               |   15 +-
1096  test-server/test-server.c             |  197 +++-
1097  test-server/test.html                 |    5 +-
1098  win32port/win32helpers/gettimeofday.c |   74 +-
1099  win32port/win32helpers/websock-w32.h  |    6 +-
1100  48 files changed, 2493 insertions(+), 4212 deletions(-)
1101
1102
1103 User api additions
1104 ------------------
1105
1106  - You can now call libwebsocket_callback_on_writable() on http connectons,
1107         and get a LWS_CALLBACK_HTTP_WRITEABLE callback, the same way you can
1108         regulate writes with a websocket protocol connection.
1109
1110  - A new member in the context creation parameter struct "ssl_cipher_list" is
1111         added, replacing CIPHERS_LIST_STRING.  NULL means use the ssl library
1112         default list of ciphers.
1113
1114  - Not really an api addition, but libwebsocket_service_fd() will now zero
1115         the revents field of the pollfd it was called with if it handled the
1116         descriptor.  So you can tell if it is a non-lws fd by checking revents
1117         after the service call... if it's still nonzero, the descriptor
1118         belongs to you and you need to take care of it.
1119
1120  - libwebsocket_rx_flow_allow_all_protocol(protocol) will unthrottle all
1121         connections with the established protocol.  It's designed to be
1122         called from user server code when it sees it can accept more input
1123         and may have throttled connections using the server rx flow apis
1124         while it was unable to accept any other input  The user server code
1125         then does not have to try to track while connections it choked, this
1126         will free up all of them in one call.
1127
1128  - there's a new, optional callback LWS_CALLBACK_CLOSED_HTTP which gets
1129         called when an HTTP protocol socket closes
1130
1131  - for LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION callback, the user_space alloc
1132         has already been done before the callback happens.  That means we can
1133         use the user parameter to the callback to contain the user pointer, and
1134         move the protocol name to the "in" parameter.  The docs for this
1135         callback are also updated to reflect how to check headers in there.
1136
1137  - libwebsocket_client_connect() is now properly nonblocking and async.  See
1138         README.coding and test-client.c for information on the callbacks you
1139         can rely on controlling the async connection period with.
1140
1141  - if your OS does not support the http_proxy environment variable convention
1142         (eg, reportedly OSX), you can use a new api libwebsocket_set_proxy()
1143         to set the proxy details in between context creation and the connection
1144         action.  For OSes that support http_proxy, that's used automatically.
1145
1146 User api changes
1147 ----------------
1148
1149  - the external poll callbacks now get the socket descriptor coming from the
1150         "in" parameter.  The user parameter provides the user_space for the
1151         wsi as it normally does on the other callbacks.
1152         LWS_CALLBACK_FILTER_NETWORK_CONNECTION also has the socket descriptor
1153         delivered by @in now instead of @user.
1154
1155  - libwebsocket_write() now returns -1 for error, or the amount of data
1156         actually accepted for send.  Under load, the OS may signal it is
1157         ready to send new data on the socket, but have only a restricted
1158         amount of memory to buffer the packet compared to usual.
1159
1160
1161 User api removal
1162 ----------------
1163
1164  - libwebsocket_ensure_user_space() is removed from the public api, if you
1165         were using it to get user_space, you need to adapt your code to only
1166         use user_space inside the user callback.
1167
1168  - CIPHERS_LIST_STRING is removed
1169
1170  - autotools build has been removed.  See README.build for info on how to
1171         use CMake for your platform
1172
1173
1174 v1.21-chrome26-firefox18
1175 ========================
1176
1177  - Fixes buffer overflow bug in max frame size handling if you used the
1178         default protocol buffer size.  If you declared rx_buffer_size in your
1179         protocol, which is recommended anyway, your code was unaffected.
1180
1181 v1.2-chrome26-firefox18
1182 =======================
1183
1184 Diffstat
1185 --------
1186
1187  .gitignore                                                      |  16 +++
1188  CMakeLists.txt                                                  | 544 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1189  LICENSE                                                         | 526 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1190  Makefile.am                                                     |   1 +
1191  README                                                          |  20 +++
1192  README.build                                                    | 258 ++++++++++++++++++++++++++++++++-----
1193  README.coding                                                   |  52 ++++++++
1194  changelog                                                       | 136 ++++++++++++++++++++
1195  cmake/FindOpenSSLbins.cmake                                     |  33 +++++
1196  config.h.cmake                                                  | 173 +++++++++++++++++++++++++
1197  configure.ac                                                    |  22 +++-
1198  lib/Makefile.am                                                 |  20 ++-
1199  lib/base64-decode.c                                             |   2 +-
1200  lib/client-handshake.c                                          | 190 +++++++++++-----------------
1201  lib/client-parser.c                                             |  88 +++++++------
1202  lib/client.c                                                    | 384 ++++++++++++++++++++++++++++++-------------------------
1203  lib/daemonize.c                                                 |  32 +++--
1204  lib/extension-deflate-frame.c                                   |  58 +++++----
1205  lib/extension-deflate-stream.c                                  |  19 ++-
1206  lib/extension-deflate-stream.h                                  |   4 +-
1207  lib/extension.c                                                 |  11 +-
1208  lib/getifaddrs.c                                                | 315 +++++++++++++++++++++++-----------------------
1209  lib/getifaddrs.h                                                |  30 ++---
1210  lib/handshake.c                                                 | 124 +++++++++++-------
1211  lib/libwebsockets.c                                             | 736 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------
1212  lib/libwebsockets.h                                             | 237 ++++++++++++++++++++++------------
1213  lib/output.c                                                    | 192 +++++++++++-----------------
1214  lib/parsers.c                                                   | 966 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------
1215  lib/private-libwebsockets.h                                     | 225 +++++++++++++++++++++------------
1216  lib/server-handshake.c                                          |  82 ++++++------
1217  lib/server.c                                                    |  96 +++++++-------
1218  libwebsockets-api-doc.html                                      | 189 ++++++++++++++++++----------
1219  libwebsockets.spec                                              |  17 +--
1220  test-server/attack.sh                                           | 148 ++++++++++++++++++++++
1221  test-server/test-client.c                                       | 125 +++++++++---------
1222  test-server/test-echo.c                                         |  31 +++--
1223  test-server/test-fraggle.c                                      |  32 ++---
1224  test-server/test-ping.c                                         |  52 ++++----
1225  test-server/test-server.c                                       | 129 ++++++++++++-------
1226  win32port/libwebsocketswin32/libwebsocketswin32.vcxproj         | 279 ----------------------------------------
1227  win32port/libwebsocketswin32/libwebsocketswin32.vcxproj.filters |  23 +++-
1228  41 files changed, 4398 insertions(+), 2219 deletions(-)
1229
1230
1231 User api additions
1232 ------------------
1233
1234  - lws_get_library_version() returns a const char * with a string like
1235          "1.1 9e7f737", representing the library version from configure.ac
1236          and the git HEAD hash the library was built from
1237
1238  - TCP Keepalive can now optionally be applied to all lws sockets, on Linux
1239         also with controllable timeout, number of probes and probe interval.
1240         (On BSD type OS, you can only use system default settings for the
1241         timing and retries, although enabling it is supported by setting
1242         ka_time to nonzero, the exact value has no meaning.)
1243         This enables detection of idle connections which are logically okay,
1244         but are in fact dead, due to network connectivity issues at the server,
1245         client, or any intermediary.  By default it's not enabled, but you
1246         can enable it by setting a non-zero timeout (in seconds) at the new
1247         ka_time member at context creation time.
1248
1249  - Two new optional user callbacks added, LWS_CALLBACK_PROTOCOL_DESTROY which
1250         is called one-time per protocol as the context is being destroyed, and
1251         LWS_CALLBACK_PROTOCOL_INIT which is called when the context is created
1252         and the protocols are added, again it's a one-time affair.
1253         This lets you manage per-protocol allocations properly including
1254         cleaning up after yourself when the server goes down.
1255
1256 User api changes
1257 ----------------
1258
1259  - libwebsocket_create_context() has changed from taking a ton of parameters
1260         to just taking a pointer to a struct containing the parameters.  The
1261         struct lws_context_creation_info is in libwebsockets.h, the members
1262         are in the same order as when they were parameters to the call
1263         previously.  The test apps are all updated accordingly so you can
1264         see example code there.
1265
1266  - Header tokens are now deleted after the websocket connection is
1267         established.  Not just the header data is saved, but the pointer and
1268         length array is also removed from (union) scope saving several hundred
1269         bytes per connection once it is established
1270
1271  - struct libwebsocket_protocols has a new member rx_buffer_size, this
1272         controls rx buffer size per connection of that protocol now.  Sources
1273         for apps built against older versions of the library won't declare
1274         this in their protocols, defaulting it to 0.  Zero buffer is legal,
1275         it causes a default buffer to be allocated (currently 4096)
1276
1277         If you want to receive only atomic frames in your user callback, you
1278         should set this to greater than your largest frame size.  If a frame
1279         comes that exceeds that, no error occurs but the callback happens as
1280         soon as the buffer limit is reached, and again if it is reached again
1281         or the frame completes.  You can detect that has happened by seeing
1282         there is still frame content pending using
1283         libwebsockets_remaining_packet_payload()
1284
1285         By correctly setting this, you can save a lot of memory when your
1286         protocol has small frames (see the test server and client sources).
1287
1288  - LWS_MAX_HEADER_LEN now defaults to 1024 and is the total amount of known
1289         header payload lws can cope with, that includes the GET URL, origin
1290         etc.  Headers not understood by lws are ignored and their payload
1291         not included in this.
1292
1293
1294 User api removals
1295 -----------------
1296
1297  - The configuration-time option MAX_USER_RX_BUFFER has been replaced by a
1298         buffer size chosen per-protocol.  For compatibility, there's a default
1299         of 4096 rx buffer, but user code should set the appropriate size for
1300         the protocol frames.
1301
1302  - LWS_INITIAL_HDR_ALLOC and LWS_ADDITIONAL_HDR_ALLOC are no longer needed
1303         and have been removed.  There's a new header management scheme that
1304         handles them in a much more compact way.
1305
1306  - libwebsockets_hangup_on_client() is removed.  If you want to close the
1307         connection you must do so from the user callback and by returning
1308         -1 from there.
1309
1310  - libwebsocket_close_and_free_session() is now private to the library code
1311         only and not exposed for user code.  If you want to close the
1312         connection, you must do so from the user callback by returning -1
1313         from there.
1314
1315
1316 New features
1317 ------------
1318
1319  - Cmake project file added, aimed initially at Windows support: this replaces
1320         the visual studio project files that were in the tree until now.
1321
1322  - CyaSSL now supported in place of OpenSSL (--use-cyassl on configure)
1323
1324  - PATH_MAX or MAX_PATH no longer needed
1325
1326  - cutomizable frame rx buffer size by protocol
1327
1328  - optional TCP keepalive so dead peers can be detected, can be enabled at
1329         context-creation time
1330
1331  - valgrind-clean: no SSL or CyaSSL: completely clean.  With OpenSSL, 88 bytes
1332         lost at OpenSSL library init and symptomless reports of uninitialized
1333         memory usage... seems to be a known and ignored problem at OpenSSL
1334
1335  - By default debug is enabled and the library is built for -O0 -g to faclitate
1336         that.  Use --disable-debug configure option to build instead with -O4
1337         and no -g (debug info), obviously providing best performance and
1338         reduced binary size.
1339
1340  - 1.0 introduced some code to try to not deflate small frames, however this
1341         seems to break when confronted with a mixture of frames above and
1342         below the threshold, so it's removed.  Veto the compression extension
1343         in your user callback if you will typically have very small frames.
1344
1345  - There are many memory usage improvements, both a reduction in malloc/
1346         realloc and architectural changes.  A websocket connection now
1347         consumes only 296 bytes with SSL or 272 bytes without on x86_64,
1348         during header processing an additional 1262 bytes is allocated in a
1349         single malloc, but is freed when the websocket connection starts.
1350         The RX frame buffer defined by the protocol in user
1351         code is also allocated per connection, this represents the largest
1352         frame you can receive atomically in that protocol.
1353
1354  - On ARM9 build, just http+ws server no extensions or ssl, <12Kbytes .text
1355         and 112 bytes per connection (+1328 only during header processing)
1356
1357
1358 v1.1-chrome26-firefox18
1359 =======================
1360
1361 Diffstat
1362 --------
1363
1364  Makefile.am                            |    4 +
1365  README-test-server                     |  291 ---
1366  README.build                           |  239 ++
1367  README.coding                          |  138 ++
1368  README.rst                             |   72 -
1369  README.test-apps                       |  272 +++
1370  configure.ac                           |  116 +-
1371  lib/Makefile.am                        |   55 +-
1372  lib/base64-decode.c                    |    5 +-
1373  lib/client-handshake.c                 |  121 +-
1374  lib/client-parser.c                    |  394 ++++
1375  lib/client.c                           |  807 +++++++
1376  lib/daemonize.c                        |  212 ++
1377  lib/extension-deflate-frame.c          |  132 +-
1378  lib/extension-deflate-stream.c         |   12 +-
1379  lib/extension-x-google-mux.c           | 1223 ----------
1380  lib/extension-x-google-mux.h           |   96 -
1381  lib/extension.c                        |    8 -
1382  lib/getifaddrs.c                       |  271 +++
1383  lib/getifaddrs.h                       |   76 +
1384  lib/handshake.c                        |  582 +----
1385  lib/libwebsockets.c                    | 2493 ++++++---------------
1386  lib/libwebsockets.h                    |  115 +-
1387  lib/md5.c                              |  217 --
1388  lib/minilex.c                          |  440 ++++
1389  lib/output.c                           |  628 ++++++
1390  lib/parsers.c                          | 2016 +++++------------
1391  lib/private-libwebsockets.h            |  284 +--
1392  lib/server-handshake.c                 |  275 +++
1393  lib/server.c                           |  377 ++++
1394  libwebsockets-api-doc.html             |  300 +--
1395  m4/ignore-me                           |    2 +
1396  test-server/Makefile.am                |  111 +-
1397  test-server/libwebsockets.org-logo.png |  Bin 0 -> 7029 bytes
1398  test-server/test-client.c              |   45 +-
1399  test-server/test-echo.c                |  330 +++
1400  test-server/test-fraggle.c             |   20 +-
1401  test-server/test-ping.c                |   22 +-
1402  test-server/test-server-extpoll.c      |  554 -----
1403  test-server/test-server.c              |  349 ++-
1404  test-server/test.html                  |    3 +-
1405  win32port/zlib/ZLib.vcxproj            |  749 ++++---
1406  win32port/zlib/ZLib.vcxproj.filters    |  188 +-
1407  win32port/zlib/adler32.c               |  348 ++-
1408  win32port/zlib/compress.c              |  160 +-
1409  win32port/zlib/crc32.c                 |  867 ++++----
1410  win32port/zlib/crc32.h                 |  882 ++++----
1411  win32port/zlib/deflate.c               | 3799 +++++++++++++++-----------------
1412  win32port/zlib/deflate.h               |  688 +++---
1413  win32port/zlib/gzclose.c               |   50 +-
1414  win32port/zlib/gzguts.h                |  325 ++-
1415  win32port/zlib/gzlib.c                 | 1157 +++++-----
1416  win32port/zlib/gzread.c                | 1242 ++++++-----
1417  win32port/zlib/gzwrite.c               | 1096 +++++----
1418  win32port/zlib/infback.c               | 1272 ++++++-----
1419  win32port/zlib/inffast.c               |  680 +++---
1420  win32port/zlib/inffast.h               |   22 +-
1421  win32port/zlib/inffixed.h              |  188 +-
1422  win32port/zlib/inflate.c               | 2976 +++++++++++++------------
1423  win32port/zlib/inflate.h               |  244 +-
1424  win32port/zlib/inftrees.c              |  636 +++---
1425  win32port/zlib/inftrees.h              |  124 +-
1426  win32port/zlib/trees.c                 | 2468 +++++++++++----------
1427  win32port/zlib/trees.h                 |  256 +--
1428  win32port/zlib/uncompr.c               |  118 +-
1429  win32port/zlib/zconf.h                 |  934 ++++----
1430  win32port/zlib/zlib.h                  | 3357 ++++++++++++++--------------
1431  win32port/zlib/zutil.c                 |  642 +++---
1432  win32port/zlib/zutil.h                 |  526 ++---
1433  69 files changed, 19556 insertions(+), 20145 deletions(-)
1434
1435 user api changes
1436 ----------------
1437
1438  - libwebsockets_serve_http_file() now takes a context as first argument
1439
1440  - libwebsockets_get_peer_addresses() now takes a context and wsi as first
1441         two arguments
1442
1443
1444 user api additions
1445 ------------------
1446
1447  - lwsl_...() logging apis, default to stderr but retargetable by user code;
1448         may be used also by user code
1449
1450  - lws_set_log_level() set which logging apis are able to emit (defaults to
1451         notice, warn, err severities), optionally set the emit callback
1452
1453  - lwsl_emit_syslog() helper callback emits to syslog
1454
1455  - lws_daemonize() helper code that forks the app into a headless daemon
1456         properly, maintains a lock file with pid in suitable for sysvinit etc to
1457         control lifecycle
1458
1459  - LWS_CALLBACK_HTTP_FILE_COMPLETION callback added since http file
1460         transfer is now asynchronous (see test server code)
1461
1462  - lws_frame_is_binary() from a wsi pointer, let you know if the received
1463         data was sent in BINARY mode
1464
1465
1466 user api removals
1467 -----------------
1468
1469  - libwebsockets_fork_service_loop() - no longer supported (had intractable problems)
1470         arrange your code to act from the user callback instead from same
1471         process context as the service loop
1472
1473  - libwebsockets_broadcast() - use libwebsocket_callback_on_writable[_all_protocol]()
1474         instead from same process context as the service loop.  See the test apps
1475         for examples.
1476
1477  - x-google-mux() removed until someone wants it
1478
1479  - pre -v13 (ancient) protocol support removed
1480
1481
1482 New features
1483 ------------
1484
1485  - echo test server and client compatible with echo.websocket.org added
1486
1487  - many new configure options (see README.build) to reduce footprint of the
1488         library to what you actually need, eg, --without-client and
1489         --without-server
1490
1491  - http + websocket server can build to as little as 12K .text for ARM
1492
1493  - no more MAX_CLIENTS limitation; adapts to support the max number of fds
1494         allowed to the process by ulimit, defaults to 1024 on Fedora and
1495         Ubuntu.  Use ulimit to control this without needing to configure
1496         the library.  Code here is smaller and faster.
1497
1498  - adaptive ratio of listen socket to connection socket service allows
1499         good behaviour under Apache ab test load.  Tested with thousands
1500         of simultaneous connections
1501
1502  - reduction in per-connection memory footprint by moving to a union to hold
1503         mutually-exclusive state for the connection
1504
1505  - robustness: Out of Memory taken care of for all allocation code now
1506
1507  - internal getifaddrs option if your toolchain lacks it (some uclibc)
1508
1509  - configurable memory limit for deflate operations
1510
1511  - improvements in SSL code nonblocking operation, possible hang solved,
1512         some SSL operations broken down into pollable states so there is
1513         no library blocking, timeout coverage for SSL_connect
1514
1515  - extpoll test server merged into single test server source
1516
1517  - robustness: library should deal with all recoverable socket conditions
1518
1519  - rx flowcontrol for backpressure notification fixed and implmeneted
1520         correctly in the test server
1521
1522  - optimal lexical parser added for header processing; all headers in a
1523         single 276-byte state table
1524
1525  - latency tracking api added (configure --with-latency)
1526
1527  - Improved in-tree documentation, REAME.build, README.coding,
1528         README.test-apps, changelog
1529
1530  - Many small fixes
1531
1532
1533 v1.0-chrome25-firefox17 (6cd1ea9b005933f)