Commit graph

1441 commits

Author SHA1 Message Date
Nick Dowell
f803c0d9df fix heap corruption if HTTP callback calls libwebsocket_close_and_free_session
Signed-off-by: Nick Dowell <nick@nickdowell.com>
2012-04-05 10:29:29 +08:00
Andy Green
fd96330920 map wsorigin on to origin at an early point and stop dupe header mem leaks
Carlo wrote

''I'm interested to use the libwebsockets server (C based) with a Java
websocket client. I was able to implement a Java websocket client based
on JWebSocket library that works fine with the libwebsockets server, but
I was obliged to patch the libwebsockets server in order to reach my
goal. In particular I patched the handshake_00() function because
JWebSocket library uses hixie 76 version. The problem was that the
JWebSocket library sends only WSI_TOKEN_SWORIGIN token instead
WSI_TOKEN_ORIGIN token. For this reason the handshake_00 failed because
the token length of WSI_TOKEN_ORIGIN was 0. I have written a patch in
order to control if at least one of the two tokens (WSI_TOKEN_SWORIGIN
and WSI_TOKEN_ORIGIN) is defined. I have attached into the e-mail the
patch. Probably it can be written better, but in any case I think that
this problem should be fixed for client/server compatibility.''

I found a simpler approach which is convert WSORIGIN processing to
go into ORIGIN token at the earliest point, then everything else can
stay the same.

I also noticed we would leak on duplicated headers and fixed that.

Reported-by: Carlo PARATA <carlo.parata@st.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2012-04-04 08:29:08 +08:00
Nick Dowell
5519d9f054 handle unsupported protocol correctly
Hi Andy,

First off, thanks for libwebsockets :-)

I've encountered a crash when a client connects to a libwebsockets server
but speicifies an unsupported protocol (Sec-WebSocket-Protocol).
handshake.c should probably be checking that wsi->protocol->name is not
null before doing a strcmp with it...
Attached is a patch for your consideration.

Cheers!
Nick

Signed-off-by: Nick Dowell <nick@nickdowell.com>
2012-04-04 08:27:35 +08:00
Andy Green
15601fd8f1 fix issuing null extension header if none supported
Josh realized that with new Chrome, because we don't support the type of
compression extension yet we returned a null extension header.

This patch fixes that by deferring issuing the extension header until we
find we have something to say.

tested OK on google-chrome 19.0.1081.2-129295

Reported-by: Josh Roberson <josh@asteriasgi.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
2012-03-29 09:27:13 +08:00
Artem Egorkine
d515ddd51d Don't care for the human-readable part of "HTTP/1.1 101" reply
While the protocol specification gives example of the
human-readable message associated with a 101-code reply,
nowhere does it actually enforce it. Ws4py gevent middleware
is known to have a message other than "Switching Protocols".
2012-02-19 17:26:17 +01:00
Dan Zhang
f2e5e985c3 cleanup fixes tested on win32 compiler
Signed-off-by: Dan Zhang <emaildanzhang@gmail.com>
2011-11-09 15:55:16 +08:00
Andy Green
20b66e9939 win32 poll emulation clean and address PEEK issue
Dan Zhang needed to defeat the recv() with PEEK in order to get working
poll() emulation on 64-bit windows.

I cleaned up the style in that file and made a version of his workaround
(which was force recv result to 0).  I can't test the result so it may
need more work.

Reported-by: Dan Zhang <emaildanzhang@gmail.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-11-09 07:28:45 +08:00
Andy Green
cc01247c50 debug move most spew into debug macro
This quietens the spew so all typical debug info now is coming from
the user code (mirror protocol in the sample server / client case).

Signed-off-by: Andy Green <andy@warmcat.com>
2011-11-07 19:53:23 +08:00
Alex Bligh
49146dbcce Add libwebsockets_ensure_user_space
This patch unifies the code for per-connection user allocation, and allows
it to be allocated earlier, duiring HTTP service time.  It's also OK to
attempt allocation multiple times, it will just return any existing
allocation.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
2011-11-07 17:19:25 +08:00
David Galeano
2f5b9bd30e add missing win32 zlib pieces
Signed-off-by: David Galeano <davidgaleano@turbulenz.biz>
2011-10-04 20:59:24 +08:00
Oleg Golosovskiy
2ef75057cd http charsets have case insensitive tokens
Andy,

According http://www.ietf.org/rfc/rfc2616.txt HTTP character sets are identified by case-insensitive tokens.

Please replase

                     if (strcmp(lws_tokens[n].token, wsi->name_buffer))
                           continue;

to

                     if (stricmp(lws_tokens[n].token, wsi->name_buffer))
                           continue;

Oleg

Also introduce strcasecmp definition for win32

Signed-off-by: Oleg Golosovskiy <ogolosovskiy@unison.com>
2011-10-04 20:20:14 +08:00
David Galeano
7b11fec7ca Added support for Windows XP. 2011-10-04 19:55:18 +08:00
David Galeano
08d60f1876 Added BYTE_ORDER definition for win32 builds. 2011-10-03 19:30:27 +08:00
Andy Green
07b56e6a8c doc LWS_EXTERN
Signed-off-by: Andy Green <andy@warmcat.com>
2011-10-03 19:30:22 +08:00
David Galeno
0644779c62 zlib update
Signed-off-by: David Galeno <davidgaleano@turbulenz.biz>
2011-09-26 17:33:45 +01:00
David Galeano
4c65884343 Added "Release DLL" configuration. 2011-09-26 17:30:34 +01:00
David Galeano
9454e21567 Added LWS_EXTERN to allow building a DLL.
Signed-off-by: David Galeano <davidgaleano@turbulenz.biz>
2011-09-26 12:17:20 +01:00
David Galeano
f70093583b Fixed compiler warnings.
Signed-off-by: David Galeano <davidgaleano@turbulenz.biz>
2011-09-26 12:09:54 +01:00
David Galeano
a0e4c88351 Ignoring Release build and opensdf files.
Signed-off-by: David Galeano <davidgaleano@turbulenz.biz>
2011-09-26 12:09:20 +01:00
Andy Green
5bf65788ea fix failure to limit 7bit lengths
Reported-by: Tran Le Hung <tranhung44@gmail.com>
Reported-by: Tobias Maier <tobias.maier@netplace.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-09-25 10:46:31 +01:00
M K
f24311527e Fix compile issue on Apple
Signed-off-by: M K <mkroehnert42@googlemail.com>
2011-09-25 10:34:35 +01:00
Andy Green
a11fe94f2c correct cpp extern only being on win32
Signed-off-by: Andy Green <andy@warmcat.com>
2011-09-25 10:30:26 +01:00
Andy Green
188d896c81 test html uplevel detect browser and MozWebSocket
Signed-off-by: Andy Green <andy@warmcat.com>
2011-09-25 10:01:02 +01:00
Andy Green
d85cb2083d v08v13 add support v13 default
Signed-off-by: Andy Green <andy@warmcat.com>
2011-09-25 09:32:54 +01:00
Andy Green
25a56b0ac3 v08 receiver ignore frame with unhandled ext opcode
Signed-off-by: Andy Green <andy@warmcat.com>
2011-09-25 08:47:57 +01:00
Andy Green
815fa23a98 v08 change ignore incoming set ext bits
Signed-off-by: Andy Green <andy@warmcat.com>
2011-09-25 08:47:53 +01:00
Andy Green
c15cb38d13 my compiler version didn't find it, but there is an uninitialized usage of
len pointed out by Sonic on the blog

Reported-by: Sven <sven@killig.de>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-06-26 10:27:28 +01:00
Andy Green
0922650b53 extensions fix deflate stream vs mux and veto it on mux children
This patch gets deflate-stream working with x-google-mux.

It adds a clean veto system where are extension can veto the proposal
of any extension when opening a new connection.  x-google-mux uses that
in its callback to defeat any use of deflate-stream on mux children.

However deflate stream is allowed on the parent connection and works
transparently now alongside x-google-mux.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-28 10:19:19 +01:00
Andy Green
5555c98728 x google mux handle illegal channel add indexes cleanup handle ch1 rx
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-26 12:59:13 +01:00
Andy Green
68b4504329 extensions introduce pre close veto
This establishes a pre-close extension check to allow an extension to
veto a close.  x-google-mux then uses this to stop ch1 going down
(subchannel 1 is the original socket connection that turns into a mux
parent) if it has active mux children; it just marks ch1 as closed in
its conn struct in that case and returns 1 from the callback to veto.

Code is also added to take care of the case ch1 is 'closed', and the
last child is subsequently closed, it actively calls close on the mux
parent then.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-25 21:41:57 +01:00
Andy Green
8c6aaa2b43 extensions change child count to highest child subchannel
This also changes the wsi_children array to be indexed by subchannel - 2,
non-existent channels are NULL in there and highest_child_subchannel
is a highwater mark for the highest subchannel ever used.  That way we
can immediately get the wsi for a subchannel at the cost of some extra
sparse skipping during management.

This also takes care of scanning for empty slots on allocation and
NULLing on close of subchannel instead of deletion.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-25 21:07:20 +01:00
Andy Green
f6652412f3 extensions ensure per conn allocation starts zeroed
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-25 20:46:18 +01:00
Andy Green
6ab0bba068 x google mux complete introduction of MUX_REAL_CHILD_INDEX_OFFSET that got included accidentally
Accidentally included half-done MUX_REAL_CHILD_INDEX_OFFSET addition a couple
of patches back after late night hacking, this patch completes it.

This makes mux added channels start at channel index 2.

1 is reserved for original carrier channel, 0 for as-yet badly defined global mux commands

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-25 12:16:00 +01:00
Jean-Pierre Gygax
f4a7c6944b add gitignore
Signed-off-by: Jean-Pierre Gygax <gygax@practicomp.ch>
2011-05-25 09:51:48 +01:00
Jean-Pierre Gygax
b422887874 win32 update for vc 2010 contributed
Signed-off-by: Jean-Pierre Gygax <gygax@practicomp.ch>
2011-05-25 09:50:58 +01:00
Andy Green
d3b421e112 remove use mux blocks macro
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-25 09:48:03 +01:00
Andy Green
a59bb9016c x google mux change to new compact channel index scheme
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 23:08:05 +01:00
Andy Green
69b6808358 x google mux introduce sticky mux opcode usage if ever used in channel
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 22:57:41 +01:00
Andy Green
66a16f393e x google mux implement child close
This implements clean client and server close for mux child connections,
and deals with accounting for parent child lists.

The mux link can then survive constant connection bringup and teardown
found in the new test client.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 22:07:45 +01:00
Andy Green
7448c7ee0b test client add flag to defeat mux extension
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 22:06:17 +01:00
Andy Green
4084af1745 test client make mirror data source channel open and close all the time
This changes the test client so that for the mirror protocol socket,
the lifetime of the connection is decided randomly to last on the order
of a second or so, then the connection is closed and a new one opened when
the close is complete.

This is to enhance testing of connection bringup and teardown especially
in mux case.

The overall functionality remains the same, spamming circles to all clients.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 22:06:17 +01:00
Michel Archembault
0054401f21 Modify Zlib VS project to be able to build in 64 bit
Signed-off-by: Michel Archembault <marchamb@matrox.com>
2011-05-24 19:07:16 +01:00
Michel Archambault
03bec393a5 Move include of gettimeofday.h to be able to build in C and C++
Signed-off-by: Michel Archambault <marchamb@matrox.com>
2011-05-24 17:15:25 +01:00
Michel Archembault
6a1b904c95 move win32 zlib to correct place
Signed-off-by: Michel Archembault <marchamb@matrox.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 16:42:42 +01:00
Andy Green
2d1301e8cb dump active protocols and extensions at context create
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 10:14:41 +01:00
Andy Green
0059754e35 fix parser reaction to zero length payloads
Zero length payloads aren't handled properly.  This patch
should solve that.

Reported-by: Chee Wooi Saw <cheewooi@gtwholdings.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 09:40:59 +01:00
Andy Green
3293c2a6f7 fix server ping coming as client payload
Client does auto-service server's ping, but then it
fell through and issued it as payload.  This fixes that
so there is no payload issued.

Reported-by: Chee Wooi Saw <cheewooi@gtwholdings.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-24 09:34:50 +01:00
Andy Green
a41314f3bf introduce x google mux very draft indeed
This is initial x-google-mux support.  It's disabled by default
since it's very pre-alpha.

1) To enable it, reconfigure with --enable-x-google-mux

2) It conflicts with deflate-stream, use the -u switch on
   the test client to disable deflate-stream

3) It deviates from the google standard by sending full
   headers in the addchannel subcommand rather than just
   changed ones from original connect

4) Quota is not implemented yet

5) Close of subchannel is not really implemented yet

6) Google opcode 0xf is changed to 0x7 to account for
   v7 protocol changes to opcode layout

However despite those caveats, in fact it can run the
test client reliably over one socket (both dumb-increment
and lws-mirror-protocol), you can open a browser on the
same test server too and see the circles, etc.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-23 10:00:03 +01:00
Michel Archambault
8214a0447e win32 update projects
Signed-off-by: Michel Archambault <marchamb@matrox.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-14 16:01:02 +02:00
Andy Green
b75c026613 remove line end at 72 for base64 encode
Reported-by: Michel Archambault <marchamb@matrox.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-14 15:08:00 +02:00