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

214 commits

Author SHA1 Message Date
stropee
e04a3cf132 http: pipeline: handle methods lacking COMPLETED_CLIENT_HTTP
Signed-off-by: stropee <simon@sirocha.fr>
2024-11-03 07:59:04 +00:00
zzblydia
fdde9119f7 client hs: fix segmentation fault
https://github.com/warmcat/libwebsockets/pull/3171
2024-06-24 09:08:31 +01:00
Andy Green
4abdfa810a client-http: use enum for failures correctly
https://github.com/warmcat/libwebsockets/issues/3159
2024-05-31 17:09:59 +01:00
c-jimenez
c57c239368 basic-auth: allow NUL in password
https://github.com/warmcat/libwebsockets/issues/3092
2024-03-11 07:54:39 +00:00
Andy Green
378ad62adf digest: only if we have tls lib to do hashing 2024-02-16 15:45:45 +00:00
Andy Green
1239a2b121 http-digest: coverity: dead code 2024-01-17 08:54:51 +00:00
Andy Green
837db622eb clean: avoid maybe-uninitialized
https://github.com/warmcat/libwebsockets/issues/3049
2024-01-16 07:15:30 +00:00
stropee
22808f049c http: fix auth digest 2023-12-27 06:34:09 +00:00
Ilya Smelykh
fdfde2ce0b http: auth digest 2023-12-08 10:25:50 +00:00
qdztxc
173c84a595 ws: tell caller we closed wsi on handshake failure
https://github.com/warmcat/libwebsockets/issues/2681
2022-07-12 09:47:56 +01:00
Ilya Smelykh
d425691d9f client: flag defeating default cache-control headers added 2021-11-11 16:55:20 +00:00
Andy Green
66afd3da78 coverity: client_reset: no longer any way to get NULL *pwsi
Coverity belatedly noticed that client_reset no longer changes *pwsi
2021-10-17 12:03:07 +01:00
Yichen Gu
b31c5d6ffe http: cookies: support cookie jar in and out 2021-08-21 17:44:40 +01:00
Andy Green
6953958fc3 http: redirect: make sure we keep wsi opaque 2021-08-19 10:01:53 +01:00
Andy Green
5b8a597c1d server: http-proxy: fix POST 2021-08-19 05:31:15 +01:00
Andy Green
d18d7a3643 http: redir: to tls from none 2021-07-30 11:32:27 +01:00
David Jeffers
c90feba3f6 gcc: gcc8 only recognizes fallthu
Later gcc is more accepting, but there's at least one gcc8 toolchain that only likes
to hear "fallthru", or it will flag it
2021-06-24 17:32:57 +01:00
Andy Green
272dba8307 http: redo redirects to follow close flow
Until now although we can follow redirects, and they can promote the
protocol from h1->h2, we couldn't handle h2 wsi reuse since there are many
states in the wsi affected by being h2.

This wipes the related states in lws_wsi_reset() and follows the generic
wsi close flow before deviating into the redirect really close to the end,
ensuring we cleaned out evidence of our previous life properly.

h2->h2 redirects work properly after this.

The max number of redirects is increased from 3 -> 4 since this was seen in
the wild with www and then geographic-based redirects.
2021-06-22 15:55:29 +01:00
Andy Green
f8f1749be9 client: add option for allowing redirect tls downgrades 2021-06-22 15:55:29 +01:00
Jed Lu
2abf4115a8 ss: direct protocol string 2021-06-11 14:44:10 +01:00
Andy Green
b28b03eee1 smp: hold pt lock for lws_client_reset removing fds
https://github.com/warmcat/libwebsockets/issues/2268
2021-04-10 06:14:12 +01:00
Andy Green
7451702722 tls-sessions: serialization 2021-04-04 05:45:53 +01:00
Andy Green
ffb49e2612 http: post: defer body pending end until no more buffered out 2021-03-25 08:40:52 +00:00
Andy Green
b5bc6028e6 http_proxy: report failed http code
Improve how we report what happened with http_proxy... if
we can't recognize the response as http/1.0 or http/1.1
do a CCE with "http_proxy fail", or if we did get valid h1
response but no 200 response code, do a CCE with
"http_proxy -> xxx" where xxx is the decimal representation
of the response code, eg, "http_proxy -> 407"
2021-03-25 08:40:52 +00:00
Andy Green
06509e287d lws_conmon: connection monitoring and stats generation
This provides a build option LWS_WITH_CONMON that lets user code recover
detailed connection stats on client connections with the LCCSCF_CONMON
flag.

In addition to latencies for dns, socket connection, tls and first protocol
response where possible, it also provides the user code an unfiltered list
of DNS responses that the client received, and the peer it actually
succeded to connect to.
2021-03-17 07:31:49 +00:00
Andy Green
3f4623bb36 lws_metrics
There are a few build options that are trying to keep and report
various statistics

 - DETAILED_LATENCY
 - SERVER_STATUS
 - WITH_STATS

remove all those and establish a generic rplacement, lws_metrics.

lws_metrics makes its stats available via an lws_system ops function
pointer that the user code can set.

Openmetrics export is supported, for, eg, prometheus scraping.
2021-03-08 21:47:28 +00:00
Andy Green
ede7f8b0f3 ss: support huge urls 2021-03-05 14:13:26 +00:00
Yichen Gu
403a6591e1 h2: client: handle END_STREAM and END_HEADERS togther on all paths 2021-01-29 21:22:35 +00:00
Andy Green
3eeda84a8d http: client: defer HUP if pending buflist 2021-01-28 05:52:44 +00:00
Andy Green
ce3b99cd8f clean: reduce logging and add some conditional debug helpers 2021-01-05 10:56:38 +00:00
Andy Green
c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
Andy Green
0ceba15d9c lws_lifecycle
This adds some new objects and helpers for keeping and logging
info on grouped allocations, a group is, eg, SS handles or client
wsis.

Allocated objects get a context-unique "tag" string intended to replace
%p / wsi pointers etc.  Pointers quickly become confusing when
allocations are freed and reused, the tag string won't repeat
until you produce 2^64 objects in a context.

In addition the tag string documents the object group, with prefixes
like "wsi-" or "vh-" and contain object-specific additional
information like the vhost name, address / port  or the role of the wsi.
At creation time the lws code can use a format string and args
to add whatever group-specific info makes sense, eg, a wsi bound
to a secure stream can also append the guid of the secure stream,
it's copied into the new object tag and so is still available
cleanly after the stream is destroyed if the wsi outlives it.
2021-01-04 05:26:50 +00:00
Andy Green
eb5f437578 h2: post: add states to wait for body 2020-12-24 16:14:36 +00:00
Andy Green
68afe5b492 ss: minimal example: testsfail
A minimal example aimed at various SS failure paths.
2020-12-24 16:14:36 +00:00
Yucong Sun
a72e975613 mingw: libevent build fixes 2020-11-28 10:58:38 +00:00
Andy Green
3549a94ce6 roles: compress role ops structs
role ops are usually only sparsely filled, there are currently 20
function pointers but several roles only fill in two.  No single
role has more than 14 of the ops.  On a 32/64 bit build this part
of the ops struct takes a fixed 80 / 160 bytes then.

First reduce the type of the callback reason part from uint16_t to
uint8_t, this saves 12 bytes unconditionally.

Change to a separate function pointer array with a nybble index
array, it costs 10 bytes for the index and a pointer to the
separate array, for 32-bit the cost is

2 + (4 x ops_used)

and for 64-bit

6 + (8 x ops_used)

for 2 x ops_used it means 32-bit: 10 vs 80 / 64-bit: 22 vs 160

For a typical system with h1 (9), h2 (14), listen (2), netlink (2),
pipe (1), raw_skt (3), ws (12), == 43 ops_used out of 140, it means
the .rodata for this reduced from 32-bit: 560 -> 174 (386 byte
saving) and 64-bit: 1120 -> 350 (770 byte saving)

This doesn't account for the changed function ops calling code, two
ways were tried, a preprocessor macro and explicit functions

For an x86_64 gcc 10 build with most options, release mode,
.text + .rodata

before patch:          553282
accessor macro:        552714 (568 byte saving)
accessor functions:    553674 (392 bytes worse than without patch)

therefore we went with the macros
2020-11-28 10:58:38 +00:00
Andy Green
44e860642b docs: switch to use main 2020-10-19 16:35:03 +01:00
Andy Green
62e566b9de client: move staged connect pieces into core-net
They have been in lib/roles/http for historical reasons, and all
ended up in client-handshake.c that doesn't describe what they
actually do any more.  Separate out the staged client connect
related stage functions into

  lib/core-net/client/client2.c: lws_client_connect_2_dnsreq()
  lib/core-net/client/client3.c: lws_client_connect_3_connect()
  lib/core-net/client/client4.c: lws_client_connect_4_established()

Move a couple of other functions from there that don't belong out to
tls-client.c and client-http.c, which is related to http and remains
in the http role dir.
2020-09-21 12:47:11 +01:00
Andy Green
e3e177a7d6 smp: add pt lock on client connect path 2020-08-31 16:51:37 +01:00
Andy Green
7ff64b3c42 coverity: 10117: help coverity understand simple_ptr cannot be NULL 2020-08-19 06:40:13 +01:00
Andy Green
5ef6c548d8 coverity: 62488 62253: comment NOP left in for extensibility 2020-08-18 14:00:54 +01:00
Andy Green
60e2c65208 coverity: 62333; no need to init cce as set on all paths that use it 2020-08-18 09:19:34 +01:00
Andy Green
400355fdc3 coverity: 62458: coverity doesnt understand nonzero header length means simple_ptr cannot be NULL 2020-08-18 09:19:33 +01:00
Andy Green
9745c5cca8 coverity: 62477: explicitly check wsi->protocol even though client creation sets it 2020-08-18 09:11:45 +01:00
Andy Green
192b76c89b coverity: 62540: explicitly check for NULL even though cannot be 2020-08-18 09:08:03 +01:00
Andy Green
0f173e0bbe coverity: 62622: remove unused line 2020-08-18 09:00:39 +01:00
Andy Green
491f0f6068 coverity: 324943: confirm get_random worked
In normal systems this doesn't have a way to fail.  But check it for
consistency.
2020-08-14 09:07:27 +01:00
Andy Green
908d259a47 coverity: 305064: clear false positive by needless NULL check
Add needless check so we don't keep getting the same coverity hit from different people
2020-08-14 07:02:07 +01:00
Andy Green
08bc9bf410 ss: http: handle rx DESTROY_ME 2020-07-21 07:57:15 +01:00
Andy Green
1a93e73402 fakewsi: replace with smaller substructure
Currently we always reserve a fakewsi per pt so events that don't have a related actual
wsi, like vhost-protocol-init or vhost cert init via protocol callback can make callbacks
that look reasonable to user protocol handler code expecting a valid wsi every time.

This patch splits out stuff that user callbacks often unconditionally expect to be in
a wsi, like context pointer, vhost pointer etc into a substructure, which is composed
into struct lws at the top of it.  Internal references (struct lws is opaque, so there
are only internal references) are all updated to go via the substructre, the compiler
should make that a NOP.

Helpers are added when fakewsi is used and referenced.

If not PLAT_FREERTOS, we continue to provide a full fakewsi in the pt as before,
although the helpers improve consistency by zeroing down the substructure.  There is
a huge amount of user code out there over the last 10 years that did not always have
the minimal examples to follow, some of it does some unexpected things.

If it is PLAT_FREERTOS, that is a newer thing in lws and users have the benefit of
being able to follow the minimal examples' approach.  For PLAT_FREERTOS we don't
reserve the fakewsi in the pt any more, saving around 800 bytes.  The helpers then
create a struct lws_a (the substructure) on the stack, zero it down (but it is only
like 4 pointers) and prepare it with whatever we know like the context.

Then we cast it to a struct lws * and use it in the user protocol handler call.
In this case, the remainder of the struct lws is undefined.  However the amount of
old protocol handlers that might touch things outside of the substructure in
PLAT_FREERTOS is very limited compared to legacy lws user code and the saving is
significant on constrained devices.

User handlers should not be touching everything in a wsi every time anyway, there
are several cases where there is no valid wsi to do the call with.  Dereference of
things outside the substructure should only happen when the callback reason shows
there is a valid wsi bound to the activity (as in all the minimal examples).
2020-07-20 06:28:52 +01:00