Commit graph

466 commits

Author SHA1 Message Date
Andy Green
2a480ea83c mingw hide some missing includes
Based on work from Radu Sorici <soriciradu@gmail.com>

Signed-off-by: Andy Green <andy.green@linaro.org>
2012-04-12 13:30:42 +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
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
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
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
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
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
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
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
Andy Green
f94e058e52 win32 move gettimeofday include inside extern c
Reported-by: Michel Archambault <marchamb@matrox.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-05-14 15:07:56 +02:00
Andy Green
043a0ba854 move send pipe choked api to public exports
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-04-25 23:54:11 +08:00
Andy Green
46c2ea0d6f pass ext pointer in ext callback
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-22 09:04:01 +00:00
Andy Green
82c3d54c10 introduce libwebsocket_is_final_fragment
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-07 21:16:31 +00:00
Andy Green
5d9d94ba09 add CONTINUATION write mode
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-07 20:47:41 +00:00
Andy Green
2836c641cf expose SHA1 api
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-07 20:47:41 +00:00
Andy Green
8acc194dc2 expose random api
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-07 20:47:40 +00:00
Andy Green
9e4c2b6e35 add separate server writeable and change naming to match rest of callbacks
Notice that the naming is changed, the notification to a server that it can write to
the client is now called LWS_CALLBACK_SERVER_WRITEABLE, and the notification to a client
that it can write to a server is LWS_CALLBACK_CLIENT_WRITEABLE.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-07 20:47:39 +00:00
Andy Green
c44159fb3a flush extensions when closing
Extensions might be caching stuff that we should spill before a controlled close.
It's not allowed to send anything on the wire after the close request, so we need
to make the extensions spill just before.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-07 07:08:18 +00:00
Andy Green
4cd87a0bd9 introduce internal extensions array
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:15:32 +00:00
Andy Green
2366b1c997 instantiate extensions server accepted
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:15:31 +00:00
Andy Green
c6517fa2ad dynamically create client extensions offer from extensions list
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:15:29 +00:00
Andy Green
57b4e9af2b document extension callback reasons
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:14:46 +00:00
Andy Green
3b84c006c9 callback each active extension on packet tx pre send
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:14:42 +00:00
Andy Green
98a717c7ed callback each active extension on packet rx pre parse
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 13:14:15 +00:00
Andy Green
c511482c78 create server extension response dynamically
This goes through the extentsions the client requested, selects the ones
that we support at the server, and then further calls back to the appropriate
protocol callback in user code to check it's OK to actually use that
extension in this context.  If it is (callback unhandled == it is) then
it's added to the list of extensions sent back to the client.

Accepted extensions are also added to the connection's active extension
list and the private "user" memory allocation for the extension context is
done and bound to the connection.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-06 10:29:35 +00:00
Andy Green
d6e09110bb introduce struct libwebsocket_extension
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-05 16:12:15 +00:00
Peter Hinz
56885f3084 introduce win32 build capability
This adds win32 build compatability to libwebsockets.

The patch is from Peter Hinz, Andy Green has cleaned it up a bit and
possibly broken win32 compatability since I can't test it, so there
may be followup patches.  It compiles fine under Linux after this
patch anyway.

Much of the patch is changing a reserved keyword for Visual C compiler
"this" to "context", but there is no real C99 support in the MSFT
compiler even though it is 2011 so C99 style array declarations
have been mangled back into "ancient C" style.

Some windows-isms are also added like closesocket() but these are
quite localized.  Win32 random is just using C library random() call
at the moment vs Linux /dev/urandom.  canonical hostname detection is
broken in win32 at the moment.

Signed-off-by: Peter Hinz <cerebusrc@gmail.com>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-02 22:03:47 +00:00
Andy Green
385e7ad034 introduce LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER
This adds a callback to protocols[0] which happens when the
Client HTTP handshake packet is being composed.  After all the
headers for the websocket handshake to the server have been
added, the callback is called with a pointer to a char *
that allows extra headers to be added.  See the comments in
libwebsocket.h or the api documentation for example code.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-01 21:06:02 +00:00
Andy Green
eeaacb39c7 introduce 76 00 client support
This adds 76/00 client support to libwebsockets.  It's still shipped
by browsers and more importantly still the only version supported by
server stuff like socket.io.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-03-01 20:44:24 +00:00
Andy Green
687b0188bc require close reason argument on close and free session
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-26 11:04:01 +00:00
Andy Green
6901cb3b4e add callback for OpenSSL client cert verification action
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-21 08:06:47 +00:00
Andy Green
c6bf2c2186 add callback to allow additional server verification certs
This adds a LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS callback
which offers a chance for the server context to be loaded with additional
certtificates allowing it to verify incoming client certs.  The callback
always comes to protocol[0].

It also introduces the context option LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT
which will enforce client cert checking on any ssl connection.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-20 11:10:47 +00:00
Andy Green
0894bda184 add callback to allow additional client verification certs
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-19 09:09:11 +00:00
Andy Green
32375b7e9e introduce listen on specific interface
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-19 08:32:53 +00:00
Darin Willits
c19456f64a Apple / iOS build compatability patch
This allows build on iOS platform, thanks Darin!

Signed-off-by: Darin Willits <darin@willits.ca>
2011-02-14 17:52:39 +00:00
Andy Green
62c54d2f56 introduce this param in callback fix server close on client socket
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-14 09:14:25 +00:00
Andy Green
4b6fbe125e unify server and client close
Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-14 08:03:48 +00:00
Andy Green
f7ee549a58 introduce-libwebsockets_hangup_on_client.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-13 09:04:21 +00:00
Andy Green
0703409235 introduce-network-connect-filter-callback.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-13 08:37:12 +00:00
Andy Green
c85619dbcd introduce-user-handshake-filter-callback.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-13 08:25:26 +00:00
Andy Green
e7981dc65a document-external-poll-support.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-12 21:24:03 +00:00
Andy Green
3221f92b1e introduce-external-poll-callbacks.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-12 13:14:11 +00:00
Andy Green
9f99034f7e export-libwebsocket_service_fd-api.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-12 11:57:45 +00:00
Andy Green
5e1fa17a6c introduce-new-05-socket-closure-rules.patch
Signed-off-by: Andy Green <andy.green@linaro.org>
2011-02-10 09:07:05 +00:00
Andy Green
bfb051f3a3 introduce-ietf-05-framing-and-commandline-options.patch
This adds 05 support, and -v switches on test-client and test-ping
to allow setting their ietf protocol version to 4 or 5.

It also optimizes the masking to us a function pointer, which
takes some conditionals out of the fast path.

Signed-off-by: Andy Green <andy@warmcat.com>
2011-02-09 08:49:14 +00:00
Andy Green
8014b29d20 introduce-k-switch-defeat-masking.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-30 20:57:25 +00:00
Andy Green
bd96d8092e introduce-LWS_WRITE_CLIENT_IGNORE_XOR_MASK.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-30 08:24:31 +00:00
Andy Green
2ac5a6fce4 fix-host-header-contents--introduce-canonical-hostname-api.patch
I?aki pointed out the dummy host field used in client test and ping
is not valid http.  This patch changes it to use the actual host
name and adds an api to collect that from the context cheaply.

Reported-by: I?aki Baz Castillo <ibc@aliax.net>
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-28 10:00:18 +00:00
Andy Green
a6cbece1ac introduce-test-ping-app.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-27 20:06:03 +00:00
Andy Green
90c7cbcc00 introduce-ssl-client-connections--flow-control.patch
Signed-off-by: Andy Green <andy@warmcat.com>
2011-01-27 06:26:52 +00:00