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.htmlhttp://localhost:7681/test.html
using keepalive correctly on the test server.
Signed-off-by: Andy Green <andy.green@linaro.org>
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>
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.
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>
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
- 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
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>