Commit graph

190 commits

Author SHA1 Message Date
Andy Green
1b89b933a6 debug spew remove ah reset logging
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-02-03 07:06:52 +08:00
Andy Green
4019aab8da ah http1.1 deal with pipelined headers properly
Connections must hold an ah for the whole time they are
processing one header set, even if eg, the headers are
fragmented and it involves network roundtrip times.

However on http1.1 / keepalive, it must drop the ah when
there are no more header sets to deal with, and reacquire
the ah later when more data appears.  It's because the
time between header sets / http1.1 requests is unbounded
and the ah would be tied up forever.

But in the case that we got pipelined http1.1 requests,
even partial already buffered, we must keep the ah,
resetting it instead of dropping it.  Because we store
the rx data conveniently in a per-tsi buffer since it only
does one thing at a time per thread, we cannot go back to
the event loop to await a new ah inside one service action.

But no problem since we definitely already have an ah,
let's just reuse it at http completion time if more rx is
already buffered.

NB: attack.sh makes request with echo | nc, this
accidentally sends a trailing '\n' from the echo showing
this problem.  With this patch attack.sh can complete well.

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-30 11:43:10 +08:00
Andy Green
1b2c9a23e1 clean pre 1.7
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-29 23:17:43 +08:00
Andy Green
8c1f6026a7 multithread stability
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-26 20:56:56 +08:00
Andy Green
5a0e7866d3 unify bounds checking in parser
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-21 10:57:39 +08:00
Andy Green
e99a83cb96 introduce LWS_WARN_UNUSED_RESULT
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 16:56:06 +08:00
Andy Green
af607da082 header fragment reject empty early
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 09:44:04 +08:00
Andy Green
f38ad33ddf tolower remove
https://github.com/warmcat/libwebsockets/issues/403

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 07:55:41 +08:00
Andy Green
bc4012916d parser issue_char audit
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-20 07:40:13 +08:00
Andy Green
d3a5505542 multithreaded service
This adds support for multithreaded service to lws without adding any
threading or locking code in the library.

At context creation time you can request split the service part of the
context into n service domains, which are load-balanced so that the most
idle one gets the next listen socket accept.

There's a single listen socket on one port still.

User code may then spawn n threads doing n service loops / poll()s
simultaneously.  Locking is only required (I think) in the existing
FD lock callbacks already handled by the pthreads server example,
and that locking takes place in user code.  So the library remains
completely agnostic about the threading / locking scheme.

And by default, it's completely compatible with one service thread
so no changes are required by people uninterested in multithreaded
service.

However for people interested in extremely lightweight mass http[s]/
ws[s] service with minimum provisioning, the library can now do
everything out of the box.

To test it, just try

$ libwebsockets-test-server-pthreads -j 8

where -j controls the number of service threads

Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-19 20:02:36 +08:00
Andy Green
9928cccdb6 fuzzer rx overflow mitigate
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-12 23:05:02 +08:00
Andy Green
6711266a50 extension permessage deflate
Signed-off-by: Andy Green <andy.green@linaro.org>
2016-01-11 11:34:01 +08:00
Andy Green
0c7e5a9418 doc improve docs around header access apis
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-30 14:53:50 +08:00
Andy Green
7dbf21efc2 autobahn extend max ping pong close payload to 125
We only supported those specific control packet payloads up to 124.
125 is the correct limit.

Lws was consistent about the wrong limit so there are no other
issues.  It doesn't affect user ABI correcting it either.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-28 13:40:54 +08:00
Andy Green
066a7a1801 close add callback to get peer close reason
https://github.com/warmcat/libwebsockets/issues/196

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-26 15:47:06 +08:00
Andy Green
3df580066b http header malloc pool implement pool
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-25 14:34:20 +08:00
Andy Green
ba38a7e6b4 ws ping buffer allocate in wsi ws union member
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-25 14:34:10 +08:00
Andy Green
e974f0c252 uridecoding lws_hdr_fragment_length
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-19 07:35:23 +08:00
Andy Green
9f54c1ff73 uridecode no need to require length plus 2
length + 1 (for the '\0' is enough)

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-18 16:40:02 +08:00
Andy Green
3ba035dc2c uridecoding disallow uriencoded equals in name part
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-18 15:40:03 +08:00
Andy Green
8b9fe99dee uridecoding handle plus chars as space
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-18 15:23:31 +08:00
Andy Green
03d7e9d331 uridecoding support optional semicolon as delimiter
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-18 15:20:09 +08:00
Andy Green
54806b1541 clean internal refactor
- Mainly symbol length reduction
 - Whitespace clean
 - Code refactor for linear flow
 - Audit @Context for API docs vs changes

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 17:03:59 +08:00
Andy Green
00c6d1579c public api remove context from user callback API BREAK
Since struct lws (wsi) now has his own context pointer,
we were able to remove the need for passing context
almost everywhere in the apis.

In turn, that means there's no real use for context being
passed to every callback; in the rare cases context is
needed user code can get it with lws_get_ctx(wsi)

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-17 07:54:44 +08:00
Andy Green
11c05bfa09 public api remove superfluous context params API BREAK
Extend the cleanout caused by wsi having a context pointer
into the public api.

There's no point keeping the 1.5 compatibility work,
we have changed the api in several places and
rebuilt wasn't going to be enough a while ago.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-16 18:19:08 +08:00
Andy Green
4eb36373d7 http uri arguments process in fragments
This makes the URI argument processing split each parameter into
a "fragment".  Processing header content as fragments already exists
in lws, because it's legal to deliver header content by repeating
the header.

Now there's an api to access individual fragments, also add the
code to the test server to print each URI argument separately.

Adapt attack.sh to parse the fragments.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 23:07:31 +08:00
Andy Green
f35801b19d URIPS_ARGUMENTS is redundant
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 23:05:23 +08:00
Andy Green
566eb4381c introduce lws_hdr_copy_fragment
This adds a public API variant of the header copy api that lets you
choose which fragment you want copied.

Normally you want the existing one that aggregates the fragments.

But it can be useful to get each part in turn (that corresponds to
the content provided by each duplicated header normally).

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 22:59:23 +08:00
Andy Green
6b5de70f4f refactor needless context with wsi paramater passing
Now we bit the bullet and gave each wsi an lws_context *, many
internal apis that take both a context and wsi parameter only
need the wsi.

Also simplify parser code by making a temp var for
allocated_headers * instead of the longwinded
dereference chain everywhere.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-15 21:15:58 +08:00
Andy Green
38f3225b22 uriencoding deal with0uriencoded question mark properly
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 19:42:26 +08:00
Andy Green
40110e84ab whitespace trailing mass cleanout
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 08:52:03 +08:00
Andy Green
8203be6742 lws_get_ctx conversion
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:43:24 +08:00
Andy Green
5c9660da61 clean tidy the worst whitespace alignment probs due to mass token name length changes
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 11:30:53 +08:00
Andy Green
4b85c1d4ac api rationalization: eliminate all libwebsocket[s]_ prefixes
This nukes all the oldstyle prefixes except in the compatibility code.

struct libwebsockets becomes struct lws too.

The api docs are updated accordingly as are the READMEs that mention
those apis.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 11:08:32 +08:00
Andy Green
3ef579b4f9 api rationalization eliminate oldstyle internal api names
Between changing to lws_ a few years ago and the previous two
patches migrating the public apis, there are only a few
internal functions left using libwebsocket_*.

Change those to also use lws_ without regard to compatibility
since they were never visible outside the library.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 09:23:56 +08:00
Andy Green
6230476455 api rationalization use new names internally
Change all internal uses of rationalized public apis to reflect the
new names.

Theer are a few things that got changed as side effect of search/replace
matches, but these are almost all internal.  I added a compatibility define
for the public enum that got renamed.

Theoretically existing code should not notice the difference from these
two patches.  And new code will find the new names.

https://github.com/warmcat/libwebsockets/issues/357

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 08:43:54 +08:00
Andrejs Hanins
765914cab1 Allow zero-length pong to be received by server
Client code already allows zero-length pongs
2015-12-01 20:59:52 +08:00
Andrew Canaday
ffe64567da C89 tweaks as per #348. 2015-11-29 19:26:01 +08:00
Andrew Canaday
4cfc42cdaa Terminate truncated header strings. 2015-11-29 19:24:04 +08:00
Andy Green
2cd3074746 mbed3 warning cleaning
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-14 16:31:01 +08:00
John Tarlton
05fc6bab0d Added callback for PONG responses 2015-10-11 16:25:57 +08:00
Andy Green
40d5abc2aa close reply must use writable control reply path
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-04-17 20:29:58 +08:00
Andy Green
8fb338f71c parser restrict unknown header paranoia to server methods
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-04-07 08:19:30 +08:00
Andy Green
2a5774edca unsigned char by default compiler compatibility
http://ml.libwebsockets.org/pipermail/libwebsockets/2015-March/001705.html

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-03-30 18:56:52 +08:00
Andy Green
106d4a8a50 ping client ping handling use same infrastructure as server
First part of this:

https://github.com/warmcat/libwebsockets/issues/256

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-03-24 21:22:52 +08:00
Andy Green
2fd6e6fb55 ping allow zero length PING
Part of

https://github.com/warmcat/libwebsockets/issues/256

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-03-24 21:07:01 +08:00
Drew Noakes
2121e8a7fc Subject: [PATCH] Fix bug parsing unknown headers.
Bug was introduced in 49f72aa45.
2015-01-30 20:09:20 +08:00
Quinlan Pfiffer
49f72aa451 Add PATCH, PUT, DELETE methods
AG: rewrite method code to use method arrays
2015-01-26 11:25:13 +08:00
Alejandro Mery
ac3ec39bb1 Subject: [PATCH] Introduce lws_free2() helper to free and re-NULL pointers
Signed-off-by: Alejandro Mery <amery@geeks.cl>
2014-12-05 07:27:52 +08:00
Alejandro Mery
6ff28248aa Subject: [PATCH] Use custom allocator
Signed-off-by: Alejandro Mery <amery@geeks.cl>
2014-12-05 07:26:26 +08:00