Commit graph

111 commits

Author SHA1 Message Date
Andy Green
2627148523 keepalive fix flow now forced closed removed
Since 0d89f3cbed added recently,
http1.1 keepalive tries to actually keep alive.

Some updates are needed to keepalive flow to solve problems coming from
changes that were hidden until now by keepalive basically closing until
recently.  It's not very noticable since clients will retry as close is
the default 1.0 behaviour... anyway this lets me do

wget http://localhost:7681/test.html http://localhost:7681/test.html

using keepalive correctly on the test server.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-10-21 08:16:34 +08:00
Ash 20001
0d89f3cbed detect http1 close connection header properly 2015-10-20 12:12:12 +08:00
Andy Green
1963c9aa7f improve callback close checking
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-10-15 07:39:33 +08:00
wonder-mice
dd32c24df6 refactor allow http parse also for client 2015-04-23 05:37:46 +08:00
Jose Luis Millan
45a04b6240 set server listening wsi use_ssl status
If the server option to allow non-ssl is enabled,
it will force this cleared when it sees that has happened
2015-03-28 10:20:50 +08:00
Andy Green
93d947c924 LWS_WITHOUT_DEBUG fix unused var
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-02-20 07:37:20 +08:00
Quinlan Pfiffer
49f72aa451 Add PATCH, PUT, DELETE methods
AG: rewrite method code to use method arrays
2015-01-26 11:25:13 +08:00
Alejandro Mery
ac3ec39bb1 Subject: [PATCH] Introduce lws_free2() helper to free and re-NULL pointers
Signed-off-by: Alejandro Mery <amery@geeks.cl>
2014-12-05 07:27:52 +08:00
Alejandro Mery
6ff28248aa Subject: [PATCH] Use custom allocator
Signed-off-by: Alejandro Mery <amery@geeks.cl>
2014-12-05 07:26:26 +08:00
Andy Green
62fe015455 revert 187
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-12-01 19:28:28 +08:00
Andy Green
28e2ab6a97 coverity 83684 more ways to close and use freed wsi
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:35:24 +08:00
Andy Green
9c8d590f9d coverity 83686 server close sockfd if failing out
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:30:57 +08:00
Andy Green
f38e7860f4 coverity 83656 server check setsockopt return
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:10:26 +08:00
Andy Green
f14ea7a906 coverity 83673 deference after NULL check
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 12:45:39 +08:00
Andy Green
3adeca8eca return_http_staus fix http2 defeating body addition
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-14 07:21:02 +08:00
Andy Green
44c116172d lws_union_transition
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-08 11:18:47 +08:00
Andrew Canaday
a19d485b80 Don't free wsi->u.hdr.ah except through lws_free_header_table (exception: server.c frees 'ah' after copying the header pointer and transitioning the union state). 2014-11-07 11:25:36 +08:00
Andy Green
97ee57fa35 http2 window update
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-02 06:54:09 +08:00
Andy Green
7f2878a503 clean remove debug spew outside http2
Found by Drew Noakes at
https://github.com/warmcat/libwebsockets/issues/190

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-01 08:41:02 +08:00
Rene Jager
c0eb2c3e9d Subject: [PATCH] fixes for handling multiple protocols in handshake 2014-10-29 09:39:34 +08:00
Andy Green
200f385716 http2 track content length add END_STREAM
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-18 12:23:05 +08:00
Andy Green
91b0589795 http2 handle flags
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-17 09:33:16 +08:00
Andy Green
917f43ab82 http2 able to send test.html to nghttp2
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-12 14:31:47 +08:00
Andy Green
2add6340d5 http2 hpack basic decode ok including huff
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-12 08:38:16 +08:00
Andy Green
07631f49af fix return_http_status adaptation for http2
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-10 06:13:40 +08:00
Christian Schüldt
fde9379e41 ssl fix service problem in MORE_SERVICE case
Signed-off-by: Christian Schüldt <crilla@kth.se>
2014-10-09 08:37:12 +08:00
Andy Green
1f5c9f0c31 ssl_capable_read add context param
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-09 08:14:30 +08:00
Andy Green
024eb6c80c http2 can keep upgraded connection up
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-08 12:00:53 +08:00
Andy Green
b08cb50e24 parser default to name parsing if unknown
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-09-30 16:33:56 +08:00
Andy Green
a54f232f07 http2 add h2c upgrade and http2 connmode
Connection upgrade handling for h2c
Establish http2 union struct and http2 connmode
No protocol code yet

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-09-30 09:43:14 +08:00
Andy Green
2af585660d confirm upgrade actually for websocket
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-09-30 08:15:49 +08:00
Andrew Canaday
af8db35010 server.c: test **truncated_send_len** for partial
Testing against truncated_send_malloc won't work if we've already
buffered and completed a partial buffer, as truncated_send_malloc
isn't free'd until the socket is destroyed.
2014-08-24 10:03:37 +08:00
Andy Green
afa10d5a89 fix spinning on NULL protocol name
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-08-11 09:11:57 +08:00
Andy Green
62824f96d4 ssl fix excessive crash workaround
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-08-10 09:50:42 +08:00
Andy Green
c949bb3b49 avoid crash if we dont have new wsi
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-07-29 23:02:07 +08:00
Andy Green
7a8d86e048 handle client protocol lists properly
We fail to deal with lists of protocols sent by the client
by picking one from the list properly.  This fixes that and
adds protocol lists to the test client for regression testing.

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-07-19 06:52:39 +08:00
Andrew Canaday
3bb0650e6a Don't need 'content_remain' in libwebsocket_read 2014-07-14 20:33:07 +08:00
Andrew Canaday
afe26cf4a6 HTTP Version, Keep-alive support, No-copy POST
This is a squashed commit from https://github.com/andrew-canaday/libwebsockets,
dev/http_keepalive branch (strategies changed a few times, so the commit
history is clutteread). This branch is submitted for clarity, but the other
can be used as a reference or alternative.

 * added **enum http_version** to track HTTP/1.0 vs HTTP/1.1 requests
 * added **enum http_connection_type** to track keep-alive vs close
 * replaced content_length_seen and body_index with **content_remain**
 * removed **post_buffer** (see handshake.c modifications)

 * removed post_buffer free

 * switch state to WSI_TOKEN_SKIPPING after URI is complete to store version
 * delete *spill* label (unused)

 * add vars to track HTTP version and connection type
 * HTTP version defaults to 1.0
 * connection type defaults to 'close' for 1.0, keep-alive for 1.1
 * additional checks in **cleanup:** label:
   * if HTTP version string is present and valid, set enum val appropriately
   * override connection default with the "Connection:" header, if present
 * set state to WSI_STATE_HTTP_BODY if content_length > 0
 * return 0 on HTTP requests, unless LWS_CALLBACK_HTTP indicates otherwise

 * add vars to track remaining content_length and body chunk size
 * re-arrange switch case order to facilitate creation of jump-table
 * added new labels:
   * **read_ok**: normal location reach on break from switch; just return 0
   * **http_complete**: check for keep-alive + init state, mode, hdr table
   * **http_new**: jump location for keep-alive when http_complete sees len>0
 * after libwebsocket_parse, jump to one of those labels based on state
 * POST body handling:
   * don't bother iterating over input byte-by-byte or using memcpy
   * just pass the relevant portion of the context->service_buffer to callback
2014-07-14 20:19:43 +08:00
Andrew Canaday
da55fb5208 Added HTTP OPTIONS support:
- added options to minilex.c
     - regenerated lextable.h
     - added WSI_TOKEN_OPTIONS_URI to libwebsockets.h
     - tweaked parsers.c to accommodate OPTIONS token
     - tweaked server.c to set uri_ptr and uri_len for HTTP callback on OPTIONS as well
2014-07-06 09:36:43 +08:00
Andrew Canaday
74b4a65745 Added optional per-header length limits:
- libwebsockets.h:
 - * added struct lws_token_limits
   * added token limits pointer to lws_context_creation_info
 - private-libwebsockets.h: added token limits pointer to lws_context_creation_info
 - context.c: copy token limits in create_context
 - client.c / server.c: pass context when invoking libwebsocket_parse
 - parsers.c:
 - * libwebsocket_parse takes context pointer
   * issue_char takes context pointer and checks header length against context limits, if defined
   * issue_char returns 1 (not -1/0) for header too long, and spill: sets the state to WSI_TOKEN_SKIPPING
2014-07-06 09:33:40 +08:00
vpeter4
7cc7ae476a Fix for binding socket to a specific interface (fixes #116)
also allow binding to IP address with @iface info.iface = "eth0"; info.iface
 = "192.168.1.5";
2014-04-28 07:32:14 +08:00
vpeter4
4dd8ada592 Disable compile warning: no newline at end of file 2014-04-27 13:28:22 +02:00
Andy Green
f004ec594e rxflow just return 0 when changing state
Nobody cares if we changed state, and callers are
increasingly taking nonzero as fail, causing us to
drop the connection when we re-enable rxflow.

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-12 11:47:25 +08:00
Andy Green
cdb9bf9bdd refactor move ssl server service to ssl.c
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-12 10:07:02 +08:00
Andy Green
a717df2739 refactor libev eliminate all code ifdefs
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-11 13:14:37 +08:00
Andy Green
a1a24d26a6 close should flush any truncated send before really closing
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-10 14:25:24 +08:00
Andy Green
d7340c141f clean=various ifdef reduction
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-10 14:08:10 +08:00
Andy Green
78f266a525 refactor use unified ssl read write functions
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-06 07:24:45 +01:00
Andy Green
c57037a555 refactor ssl related code into ssl.c
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-03 10:17:00 +08:00
Andy Green
aad2eac48e refactor handshake client and server handling into client.c and server.c
Eliminate more #ifdefs

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-03 09:03:37 +08:00