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

571 commits

Author SHA1 Message Date
Andy Green
bc0ab4b656 http server: favour redirect over ws upgrade 2020-01-10 11:03:00 +00:00
Andy Green
db15061e87 ah: simple_create an empty string removes header entry
Length is zero either way

https://github.com/warmcat/libwebsockets/issues/1820
2020-01-10 10:05:35 +00:00
Christian Thießen
6555d4d51c http client: Fix overwite of addrlen for connect if binding to iface
The addrlen argument to connect() was overwritten by the
lws_socket_bind() result, which is a port number.
Fixes https://github.com/warmcat/libwebsockets/issues/1817
2020-01-10 05:55:25 +00:00
Andy Green
0bfd39135e cleaning 2020-01-05 22:17:58 +00:00
Andy Green
7dcb4eeaa6 reverse-proxy: allow proxying rfc8441 ws CONNECT
Take the opportunity to provide public method index constants
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
9cb4f25476 h2: LCCSCF_H2_MANUAL_RXFLOW and refactor txcr
This changes the approach of tx credit management to set the
initial stream tx credit window to zero.  This is the only way
with RFC7540 to gain the ability to selectively precisely rx
flow control incoming streams.

At the time the headers are sent, a WINDOW_UPDATE is sent with
the initial tx credit towards us for that specific stream.  By
default, this acts as before with a 256KB window added for both
the stream and the nwsi, and additional window management sent
as stuff is received.

It's now also possible to set a member in the client info
struct and a new option LCCSCF_H2_MANUAL_RXFLOW to precisely
manage both the initial tx credit for a specific stream and
the ongoing rate limit by meting out further tx credit
manually.

Add another minimal example http-client-h2-rxflow demonstrating how
to force a connection's peer's initial budget to transmit to us
and control it during the connection lifetime to restrict the amount
of incoming data we have to buffer.
2020-01-02 08:31:02 +00:00
Andy Green
22a6a0073d safari: update default CSP to specify ws and wss schema
https://github.com/warmcat/libwebsockets/issues/1806
2019-12-29 19:59:16 +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
c4ab815aaf _GNU_SOURCE: only define if not already defined
https://github.com/warmcat/libwebsockets/issues/1803
2019-12-22 18:17:45 +00:00
Andy Green
d911bce379 spa: report 0-length FINAL_CONTENT
https://github.com/warmcat/libwebsockets/issues/1468

Just always report FINAL_CONTENT at the end, a zero length one
is okay.
2019-12-22 18:17:45 +00:00
Andy Green
c21f2dbe46 lextable: fix x-forwarded-for
https://github.com/warmcat/libwebsockets/issues/1801
2019-12-20 18:42:29 +00:00
Dane
10290048b0 basic auth: add callback option
Allow an http mount to specify it wants to check Basic Auth
requests via a protocol callback instead of a text file.
2019-12-14 23:55:28 +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
68de449093 raw: client: make sure we get CONNECT and opaque_user_data before RX 2019-12-02 11:19:32 +00:00
Andy Green
277d0e5e4c license: fix up last mentions of lgpl outside of the source file license grant part 2019-12-02 11:19:30 +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
9d93677d7d ws pmd: deflatePending only has meaning during deflate
https://github.com/warmcat/libwebsockets/issues/1768
2019-11-23 07:44:05 +00:00
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