1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
Commit graph

651 commits

Author SHA1 Message Date
Andy Green
0df23ef53b connect: fix getaddrinfo leak 2019-11-20 10:21:30 +00:00
Andy Green
092ebf9879 cgi: minimal example 2019-11-20 05:20:59 +00:00
Andy Green
0f7f27801e http redirect: 303: force method to GET
This teaches http client stuff how to handle 303 redirects... these
can happen after POST where the server side wants you to come back with
a GET to the Location: mentioned.

lws client will follow the redirect and force GET, this works for both
h1 and h2.  Client protocol handler has to act differently if it finds
it is connecting for the initial POST or the subsequent GET, it can
find out which by checking a new api lws_http_is_redirected_to_get(wsi)
which returns nonzero if in GET mode.

Minimal example for server form-post has a new --303 switch to enable
this behaviour there and the client post example has additions to
check lws_http_is_redirected_to_get().
2019-11-17 10:47:01 +00:00
Andy Green
285fb9c8ba server vfs: close: cleanup also at just_kill_connection
Also make sure to close the vfs handle on transaction completed as
well as close.
2019-11-16 09:00:15 +00:00
Andy Green
1d3e103c74 server: vfs: make sure handle freed if problems while setting up file transfer
https://github.com/warmcat/libwebsockets/issues/1765
2019-11-16 09:00:15 +00:00
Andy Green
724f4e9f22 http: chunked client 2019-11-16 09:00:15 +00:00
Andy Green
1968edcf44 cgi: reenable h1 with chunking 2019-11-16 09:00:15 +00:00
Andy Green
44585d0fc0 http_proxy: fixes
Eg,

http_proxy=http://127.0.0.1:3128 ./bin/lws-minimal-http-client

works OK on h1 + h2
2019-11-15 08:28:50 +00:00
Andy Green
6975847e62 lws_getaddrinfov46: make sure to set ai_socktype for ipv6 2019-11-13 09:15:36 +00:00
Andy Green
4f6fdd41b9 h2 client: no point resetting ah
Resetting the ah and waiting a bit is the right strategy at the end of
http/1.1 client transaction.  But it's wrong for h2... drop the ah
instead if it's the end of a client transaction on h2.
2019-11-08 08:46:57 +00:00
Andy Green
c8de9bbc2d ah: drop on LONG_POLL and allow dropping client ah early 2019-11-06 21:34:14 +00:00
Andy Green
6b4b2f28be alpn: move out of tls-server so it can be used if server disabled 2019-11-06 06:39:28 +00:00
Andy Green
37c198d40b format strings: fixes for when toolchain has uint32_t as unsigned long 2019-11-05 21:00:45 +00:00
Andy Green
38e43bb51e ws-over-h2: disable validity checking on encapsulated wsi
The h2 nwsi is subject to its own validity checking PINGs,
we don't need to also do them to encapsulated ws-over-h2
2019-11-05 04:53:09 +00:00
Andy Green
6786ce9e33 ws-over-h2: wrong sid on rst_stream
rst_stream is almost always called from the h2 parser... in the case
a ws-over-h2 is closing though, it can't reference the h2n parser sid
context to get the sid to send... it's unrelated at that time.

https://bugzilla.mozilla.org/show_bug.cgi?id=1590299
https://github.com/warmcat/libwebsockets/issues/1752
2019-11-04 21:19:53 +00:00
Andy Green
0ab4a707fb format strings: ban %.*s as some platforms lack it
The %.*s is very handy to print strings where you have a length, but
there is no NUL termination.  It's quite widely supported but at least
one vendor RTOS toolchain doesn't have it.

Since there aren't that many uses of it yet, audit all uses and
convert to a new helper lws_strnncpy() which uses the smaller of
two lengths.
2019-11-04 13:49:14 +00:00
Andy Green
f3b2205679 clean: warning where uint32_t is long 2019-10-31 11:01:39 +00:00
Kristján Valur Jónsson
4c224eb64b fix integer conversions from 64 bit 2019-10-27 16:29:04 +00:00
Andy Green
186888ed39 ws proxy: ensure upgrade request url starts with slash
In the case rpath is set to //, any urlargs will be added
right at the start.  Add a check to keep the initial / if so.

https://github.com/warmcat/libwebsockets/issues/1733
2019-10-26 05:31:01 +01:00
Andy Green
da2d585583 rtos: h2 in toolchain with long uint32_t 2019-10-17 11:08:47 +01:00
Andy Green
08e008ac3d h2 client: deal correctly with zero length DATA with END_STREAM 2019-10-17 09:19:57 +01:00
Andy Green
fe1d3def00 lws_spa: also support multipart/related 2019-10-14 12:22:46 +01:00
Andy Green
667f9d1fb3 validity: encapsulated ws must report validity on parent h2 conn 2019-10-14 10:53:28 +01:00
Andy Green
938f692c48 adopt: improve logging of server adopt fail
This is usually something that either couldn't negotate tls at all
or compatible tls parameters.

Log the vhost it came in on and the IP.
2019-10-14 07:08:57 +01:00
Andy Green
da8995bb61 h2: tolerate unexpected server behaviour
Make sure we only do one SETTINGS ack handling

Fix corner case of ignored header with 0 data being the last in the HEADERS
2019-10-12 12:41:14 +01:00
Andy Green
300e22c815 lws_system: auth token handling using buflist 2019-10-12 12:41:14 +01:00
Andy Green
37ac955fc4 wsi flags: extra encodings 2019-10-12 12:41:14 +01:00
Andy Green
127e53cf98 client: multipart mime generation helpers
lws has been able to generate client multipart mime as shown
in minimal-http-client-post, but it requires a lot of user
boilerplate to handle the boundary, related transaction header,
and multipart headers.

This patch adds a client creation flag to indicate it will
carry multipart mime, which autocreates the boundary string
and applies the transaction header with it, and an api to
form the boundary headers between the different mime parts
and the terminating boundary.
2019-10-12 12:41:14 +01:00
Andy Green
ba8402b43f coverity: use function comments to clear false positives 2019-10-12 12:41:14 +01:00
Zhiwen Zheng
70d2ca94b5 cgi: fix passing cgi envs using setenv() 2019-10-12 12:41:14 +01:00
Andy Green
a83c6439e6 client h2: auth bearer option flag
This affects max header size since we use the latter half
of the pt_serv_buf to prepare the (possibly huge) auth token.

Adapt the pt_serv_buf_size in the hugeurl example.
2019-10-12 12:41:14 +01:00
Andy Green
07495c20c8 h2: overflow quirk
Some servers set the tx credit to the absolute max and then add to it... this is illegal
(and checked for in h2spec).  Add a quirk flag that works around it by reducing the
initial tx credit size by a factor of 16.
2019-10-12 12:41:14 +01:00
Andy Green
6feb51fd42 h2: ack SETTINGS just the once 2019-10-12 12:41:14 +01:00
Andy Green
b40e19edca h2: end stream with end headers
This shouldn't be necessary; just END_HEADERS flag should be enough.
But nghttp2 will not talk to us unless we end the stream from our side.

Unfortunately ending the stream at the time we sent the headers means
we cannot support the long poll half-close scheme.  So add a quirk
flag to optionally support this behaviour of nghttp2 when the client
is creating the connection.
2019-10-12 12:41:14 +01:00
Andy Green
abea7da587 h2: we dont support PUSH 2019-10-12 12:41:14 +01:00
Andy Green
f4b38f104c LWS_WITH_UDP 2019-10-12 12:41:14 +01:00
Andy Green
fc295b7959 muxable client: make http support generic
h1 and h2 has a bunch of code supporting autobinding outgoing client connections
to be streams in, or queued as pipelined on, the same / existing single network
connection, if it's to the same endpoint.

Adapt this http-specific code and active connection tracking to be usable for
generic muxable protocols the same way.
2019-10-10 16:34:37 +01:00
Andy Green
94f1c7b0c1 lws_system: ntpclient 2019-10-10 16:34:37 +01:00
Andy Green
04f99f1499 lws_retry: udp support 2019-10-10 16:34:37 +01:00
Andy Green
6a6f365ce7 semmle: fix warnings
They're all cosmetic or minor js stuff.

Add related shield.io icons to README.
2019-09-22 09:35:07 -07:00
Andy Green
f9f6bb66fe lws_validity: unified connection validity tracking
Refactor everything around ping / pong handling in ws and h2, so there
is instead a protocol-independent validity lws_sul tracking how long it
has been since the last exchange that confirms the operation of the
network connection in both directions.

Clean out periodic role callback and replace the last two role users
with discrete lws_sul for each pt.
2019-09-22 09:35:07 -07:00
Andy Green
ba754c4cb2 h2: unify immortal stream tracking across SSE and ws substreams
It was already correct but add helpers to isolate and deduplicate
processing adding and closing a generically immortal stream.

Change the default 31s h2 network connection timeout to be settable
by .keepalive_timeout if nonzero.

Add a public api allowing a client h2 stream to transition to
half-closed LOCAL (by sending a 0-byte DATA with END_STREAM) and
mark itself as immortal to create a read-only long-poll stream
if the server allows it.

Add a vhost server option flag LWS_SERVER_OPTION_VH_H2_HALF_CLOSED_LONG_POLL
which allows the vhost to treat half-closed remotes as immortal long
poll streams.
2019-09-22 03:08:36 -07:00
Andy Green
4e8497b28a context-vhost options: move to uint64_t 2019-09-22 03:08:36 -07:00
Andy Green
6710279e21 client: use block parse and buflist
With http, the protocol doesn't indicate where the headers end and the
next transaction or body begin.  Until now, we handled that for client
header response parsing by reading from the tls buffer bytewise.

This modernizes the code to read in up to 256-byte chunks and parse
the chunks in one hit (the parse API is already set up for doing this
elsewhere).

Now we have a generic input buflist, adapt the parser loop to go through
that and arrange that any leftovers are placed on there.
2019-09-22 03:08:36 -07:00
Andy Green
78c7b0651e buflist: add static reason logging to internal aware apis 2019-09-22 03:08:36 -07:00
Andy Green
32a35d0c4b fixes: various small fixes 2019-09-22 03:08:36 -07:00
Andy Green
5f4dce6942 parsers: use common unaligned accessors 2019-09-22 03:08:36 -07:00
Andy Green
7528491505 raw-proxy: don't defer to raw-skt if we wanted raw-proxy
At some point raw-skt became the default that overrode
the raw-proxy binding request.  Don't do that if we can
see we specifically wanted raw-proxy.
2019-09-22 03:08:36 -07:00
Andy Green
3452980391 PEER_LIMITS: add lejp-conf 2019-09-22 03:08:36 -07:00
Andy Green
0fb976837b tls certs: update warmcat.com and libwebsockets.org public certs
Old certs were getting near the end of their life and we switched the
server to use letsencrypt.  The root and intermediate needed for the
mbedtls case changed accordingly
2019-09-22 03:08:36 -07:00