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

214 commits

Author SHA1 Message Date
Andy Green
0bfd39135e cleaning 2020-01-05 22:17:58 +00:00
Andy Green
2b456e734a client: make sure h2 direct mux get ESTABLISHED_CLIENT_HTTP 2020-01-05 22:17:58 +00:00
Andy Green
7221bc57b5 mux children: generalize helpers out of h2 implementation
This should be a NOP for h2 support and only affects internal
apis.  But it lets us reuse the working and reliable h2 mux
arrangements directly in other protocols later, and share code
so building for h2 + new protocols can take advantage of common
mux child handling struct and code.

Break out common mux handling struct into its own type.

Convert all uses of members that used to be in wsi->h2 to wsi->mux

Audit all references to the members and break out generic helpers
for anything that is useful for other mux-capable protocols to
reuse wsi->mux related features.
2019-12-29 19:59:16 +00:00
Andy Green
1eb4d335d2 active_conns: move out dependency on ah 2019-12-23 09:25:56 +00:00
Andy Green
36de0ada7d http client basic auth add helper and example 2019-12-22 18:17:45 +00:00
Andy Green
392dfe186b LWS_ERRNO: audit uses for case logging may destroy errno
On some platforms, it's possible that logging flow may reset errno.  In the case where
we try to log errno on those platforms and afterwards try to query it, we will get a
nasty surprise that the logged errno is destroyed by the time we come to test it.

In the two cases of this in the tree at the moment, sample errno into a temp and
log and test the temp.

Thanks to Sakthi Ramabadran for finding this.
2019-12-14 23:55:28 +00:00
Andy Green
74712ea4f5 socks5: fix compile breakage
https://github.com/warmcat/libwebsockets/issues/1777
2019-11-27 19:19:48 +00:00
Andy Green
0df23ef53b connect: fix getaddrinfo leak 2019-11-20 10:21:30 +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
724f4e9f22 http: chunked client 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
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
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
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
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
32a35d0c4b fixes: various small fixes 2019-09-22 03:08:36 -07:00
Andy Green
49f78ed0d7 client: improve redirect 2019-09-22 03:07:57 -07:00
Andy Green
d808748cd6 detailed latency stats
Remove LWS_LATENCY.

Add the option LWS_WITH_DETAILED_LATENCY, allowing lws to collect very detailed
information on every read and write, and allow the user code to provide
a callback to process events.
2019-09-22 03:06:59 -07:00
Andy Green
5c3e8b2e41 client: iterate connection attempts through addrinfo list 2019-09-22 03:06:59 -07:00
Andy Green
c591e1adfc asynchronous dns for ipv4 and ipv6
This adds the option to have lws do its own dns resolution on
the event loop, without blocking.  Existing implementations get
the name resolution done by the libc, which is blocking.  In
the case you are opening client connections but need to carefully
manage latency, another connection opening and doing the name
resolution becomes a big problem.

Currently it supports

 - ipv4 / A records
 - ipv6 / AAAA records
 - ipv4-over-ipv6 ::ffff:1.2.3.4 A record promotion for ipv6
 - only one server supported over UDP :53
 - nameserver discovery on linux, windows, freertos

It also has some nice advantages

 - lws-style paranoid response parsing
 - random unique tid generation to increase difficulty of poisoning
 - it's really integrated with the lws event loop, it does not spawn
   threads or use the libc resolver, and of course no blocking at all
 - platform-specific server address capturing (from /etc/resolv.conf
   on linux, windows apis on windows)
 - it has LRU caching
 - piggybacking (multiple requests before the first completes go on
   a list on the first request, not spawn multiple requests)
 - observes TTL in cache
 - TTL and timeout use lws_sul timers on the event loop
 - ipv6 pieces only built if cmake LWS_IPV6 enabled
2019-09-19 06:54:53 +01:00
Sviatoslav Grebenchucov
976d804f1a socks: Fix compilation error 2019-09-06 15:30:51 +01:00
Andy Green
0fa5563d18 freertos: rename esp32 plat to freertos 2019-08-26 09:58:57 +01:00
Andy Green
f8afcd0e5c client: make external http proxying optional
Add LWS_CLIENT_HTTP_PROXYING on by default.  Removing it saves a few
hundred bytes of code and 128 bytes per vhost in heap.
2019-08-26 09:58:57 +01:00
Andy Green
c099e7be92 client: do client stash in a single alloc
Improve the code around stash, getting rid of the strdups for a net
code reduction.  Remove the special destroy helper for stash since
it becomes a one-liner.

Trade several stack allocs in the client reset function for a single
sized brief heap alloc to reduce peak stack alloc by around 700 bytes.
2019-08-19 10:12:20 +01:00
Andy Green
d7f0521aeb private.h: rename to contain dir
Having unique private header names is a requirement of a particular
platform build system it's desirable to work with
2019-08-15 10:49:52 +01:00
Andy Green
26319663f7 license: switch LGPLv2.1+SLE parts to MIT 2019-08-14 10:44:38 +01:00
Andy Green
7b517eac87 lws_inform_client_conn_fail
There are many places where we have the same code to inform about client
connection failure... consolidate it
2019-08-12 12:44:36 +01:00
Andy Green
3c12fd72e8 unify us sorted waits
There are quite a few linked-lists of things that want events after
some period.  This introduces a type binding an lws_dll2 for the
list and a lws_usec_t for the duration.

The wsi timeouts, the hrtimer and the sequencer timeouts are converted
to use these, also in the common event wait calculation.
2019-08-08 22:39:47 +01:00
Andy Green
45ec3ce369 lws_dll: upgrade all instances to lws_dll2
lws_dll2 removes the downsides of lws_dll and adds new features like a
running member count and explicit owner type... it's cleaner and more
robust (eg, nodes know their owner, so they can casually switch between
list owners and remove themselves without the code knowing the owner).

This deprecates lws_dll, but since it's public it allows it to continue
to be built for 4.0 release if you give cmake LWS_WITH_DEPRECATED_LWS_DLL.

All remaining internal users of lws_dll are migrated to lws_dll2.
2019-08-08 16:58:55 +01:00
Andy Green
6dd65e2d75 COVA10117: help coverity see uri is always set
The _WSI_TOKEN_CLIENT_URI private header was always
set to something by the client api before this.  Help
Coverity understand it's OK.
2019-08-08 09:45:09 +01:00
Andy Green
7f6afa6985 COVA11626: explicitly check there is a protocol set 2019-08-08 09:45:09 +01:00
hjfbswb
15ce3d03b9 solve complilation errors on vs2008
replace snprintf with lws_snprintf
2019-08-01 18:05:38 +01:00
Andy Green
00923627c0 client: add more descriptive string cases 2019-07-24 16:48:24 -07:00
Andy Green
2c143ed224 COVA10117: help Coverity understand the address cannot be NULL 2019-07-16 10:02:54 -07:00
Andy Green
bc394b0680 ws: http: most of the world can't handle close,upgrade on connection
It's legal and does something important, if the upgrade fails and stays in http,
it describes how the connection should be handled after sending the error code.

But most ws servers can't cope with it...
2019-07-14 15:45:32 -07:00
Andy Green
fc5defdd2a COVA10299: check lws_change_pollfd 2019-07-13 13:39:50 -07:00
Andy Green
e3f895a71d COVA11626: pwsi is not allowed to be NULL 2019-07-13 13:28:54 -07:00
Andy Green
cd56a4b97f COVA12046: make it clear the strdup target cannot be NULL 2019-07-13 13:28:54 -07:00
Andy Green
d14dcff076 COVA11197: source indentation confused 2019-07-13 13:28:54 -07:00
Andy Green
93df14454c COVA10821: check lws_change_pollfd 2019-07-13 13:28:54 -07:00
Andy Green
e4ec282987 coverity: 2019.03 fixes 2019-07-01 06:39:55 +01:00