Commit graph

1087 commits

Author SHA1 Message Date
Andy Green
28b12ad0af ssl output handle want read write
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-23 12:02:52 +08:00
Andy Green
35c80f9885 ssl add SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER to server and client
gaby64 at githib found this option is necessary when using SSL with the
truncated send support

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-23 11:53:07 +08:00
Andy Green
e254d9589d truncated send keep and grow truncation buffer
Also change from looking at wsi->truncated_send_malloc to see if we are in the middle of
dealing with a truncated send to looking for nonzero wsi->truncated_send_len

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-23 11:41:15 +08:00
Andy Green
27e770b0ef clean output.c a little
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-23 11:21:51 +08:00
Andy Green
564056d27c nonzero return from client parser is close
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-17 18:40:08 +08:00
Andy Green
d2ec7adbab ssl client use OS CA root certs by default
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-15 10:39:29 +08:00
Andy Green
5ac7e7ad5a client allow user callback to close on nonzero return
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-15 09:32:40 +08:00
Andy Green
bbc5c07054 upgrade and improve storage efficiency of minilex
Until now minilex has done fine with providing a simple and fast header
decode state machine.  But for HTTP2.0, new headers must be added and it
is already on the limit of table branching in 1 byte (already using +0xf8
of a max limit of 0xff).

This changes the minilex format to improve storage size without loss of
decode efficiency.  It reduces the curent lws header table from 546 -> 403
bytes and upgrades the ability to increase table size by allowing jumps
to increase from the old limit of +255 states to +65535 states, which should
be enough for anything we ever want to do.

The max number of terminals is also increased from 128 to 2048.

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-09 11:49:21 +08:00
Patrick Gansterer
1ee57f6fe8 Add libwebsocket_cancel_service() to let a pending libwebsocket_service() return
Use poll() with a pipe instead of ppoll() to allow the stop polling
on all UNIX platforms.
2014-03-08 09:31:49 +08:00
Patrick Gansterer
cb6ee152d2 Define libwebsocket_write_http as a macro instead of inline
This solves two problems:
a) We do not need to use the keyword inline in the public header.
b) We avoid a possible warning about an unused static function.
2014-03-03 19:50:42 +08:00
Andy Green
ae1a8be61a win32 provide empty declaration for inline
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-03 07:21:30 +08:00
Patrick Gansterer
4a83727bf6 Remove duplicated implementations for bzero()
Define bzero() in a central place if HAVE_BZERO is not set
2014-02-28 20:28:06 +08:00
Patrick Gansterer
2dbd837c41 WSAGetLastError() instead of errno on Windows
Error codes set by Windows Sockets are not made available through the errno
variable. Checking them via WSAGetLastError() is the corret solution.
2014-02-28 20:08:55 +08:00
Patrick Gansterer
61a6ae4f77 Check if getenv() exists
Do not call getenv() on platform which do not support it
2014-02-28 09:42:12 +08:00
Patrick Gansterer
148b945f7f Allow setting the HTTP proxy via creation info
If the user provides a proxy via the info object it is used
in favor over the http_proxy environment variable.
2014-02-28 09:39:21 +08:00
Andy Green
02684c54fb fix missing include for time
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-28 09:09:17 +08:00
Patrick Gansterer
5b71aac2ed Enable compilation on Windows CE
Add a few ifdefs to support this additional platform.
2014-02-28 09:01:06 +08:00
Patrick Gansterer
cd9d6c5149 Correctly server non-ASCII filenames on Windows
Convert the filename from UTF-8 to UTF-16 and use CreateFileW() to open the file.
2014-02-28 08:59:58 +08:00
Patrick Gansterer
9d614917c3 Add dummy implementation when strerror() is missing
Use a simple empty string for platforms without an implementation.
2014-02-28 08:57:01 +08:00
Patrick Gansterer
e5720a347e Cleanup include statements
Remove useless includes and add some preprocessor conditions for platform specific headers.
2014-02-28 08:51:35 +08:00
Patrick Gansterer
ce8079c09b Add explicit cast to setsockopt() calls
Implicit cast from size_t* to const char* throws an error on some compilers.
2014-02-28 08:45:19 +08:00
Patrick Gansterer
fce64cda4c Fix Content-Type header of http status response
The header for setting the mime type is called ‘Content-Type’ and not ‘Mime-Type’.
2014-02-27 21:29:48 +08:00
Patrick Gansterer
81338aa886 Use native file functions on Windows
Add a special implementation with CreateFile(), ReadFile() and CloseFile()
for serving HTTP file request to allow compilation on all Windows platforms.
2014-02-27 21:20:36 +08:00
Patrick Gansterer
3ef96e8095 Rename leave to cleanup
The name ‘leave’ can not be used on some Windows CE platforms, so rename it.
2014-02-27 21:16:00 +08:00
Patrick Gansterer
92792b4eef Avoid calls to gettimeofday()
Add a new function to get the current time in microseconds, since gettimeofday() does not exist on Windows.
Keep the current implementation for the test applications.
2014-02-27 21:04:18 +08:00
Patrick Gansterer
7769a2d07e Replace perror() with lwsl_warn()
Use the general logging function for printing error messages.
2014-02-27 20:57:43 +08:00
Patrick Gansterer
b37bd6ce5c Fix endian detection on non-linux systems
f975f73640 introduced inclusion of endian.h,
which is not a standard header. Only include it on Linux machines and
add similar includes for Apple and FreeBSD.
2014-02-27 20:52:01 +08:00
Patrick Gansterer
2ff6955046 Add missing LWS_VISIBLE to libwebsocket_set_timeout()
This aligns it with the style of all other function declarations.
2014-02-27 20:46:38 +08:00
Andy Green
83725d8cd4 revert wrong fix visibility of return_http_status
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-27 07:19:21 +08:00
Joakim Soderberg
7b7b7b2734 Fix windows compilation. 2014-02-27 07:15:24 +08:00
Gabriel Gritsch
86267d94ad use SO_REUSEADDR on windows since supposedly ok now 2014-02-22 18:00:28 +08:00
Andy Green
6afb19ac2c fix visibility of return_http_status
From "DevYourWorld" on github

https://github.com/warmcat/libwebsockets/issues/64#issuecomment-35720037

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-21 18:51:38 +08:00
Andy Green
92f9b16c9e interface_to_sa no longer server only
Via "DevYourWorld" on github

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

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-21 18:43:42 +08:00
Craig McQueen
e049a77775 Call libwebsocket_set_timeout() before callback LWS_CALLBACK_HTTP.
This allows the LWS_CALLBACK_HTTP callback to override the timeout
with libwebsocket_set_timeout() if it wants.
2014-02-20 07:51:10 +08:00
Mattias Lundberg
03bb8f9045 Add support to binding client to interface. 2014-02-19 08:38:08 +08:00
Joakim Soderberg
6596e4b2f5 Fix compilation on Windows.
C89 which Microsofts compiler only support does not allow variable
declarations anywhere but at the start of a scope.

Also, only try to copy the test-server files if they actually exists. For
instance the OpenSSL cert generation fails if you run cmake under the git
bash shell on Windows (won't work with the unix method either) so that
file will be missing... This would result in a compilation error when
tests where turned on.
2014-02-19 08:37:50 +08:00
Craig McQueen
e7fd8b199e Add LWS_VISIBLE to libwebsocket_set_timeout() so it can be used externally. 2014-02-19 08:32:04 +08:00
Michael Haberler
8284cf18ad document new extpoll apis 2014-02-15 20:35:05 +08:00
Michael Haberler
ffbc02ff11 change extpoll in lib to new way 2014-02-15 20:35:05 +08:00
Michael Haberler
b309305a7e replace old extpoll callbacks with LWS_CALLBACK_CHANGE_MODE_POLL_FD 2014-02-15 20:18:24 +08:00
Michael Haberler
cb7330680e define struct libwebsocket_pollargs 2014-02-15 20:15:55 +08:00
Andy Green
76b6ea191c add outermost wsi lifetime callbacks
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-15 19:25:50 +08:00
Andy Green
09f005819a LWS_CALLBACK_USER
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-15 16:49:41 +08:00
Andy Green
e39e6ef926 libwebsocket_callback_all_protocol
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-15 16:36:38 +08:00
Gabriel Gritsch
890f8e992b add const http write helper
Since libwebsocket_write doesn't change the source buffer in HTTP protocol,
we can have a little helper to hide the harmless cast
2014-02-15 16:20:25 +08:00
Andy Green
8ea1955c3e fix zero length ping pong
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-15 16:00:37 +08:00
Daniel Ludwig
f975f73640 missing endian preprocessor defines on Linux environments 2014-02-15 15:07:03 +08:00
arnaudviala
7c6f26c62c fix memory leak
Fix a possible memory leak in
 libwebsocket_context_destroy() when compiled without extension support.
2014-02-15 14:39:40 +08:00
Andy Green
176de27df6 add timeout between accept and negotiation
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-15 14:36:02 +08:00
Alexandre Erwin Ittner
d578f57f7f Fix documentation for LWS_CALLBACK_FILTER_NETWORK_CONNECTION
At the time callback LWS_CALLBACK_FILTER_NETWORK_CONNECTION is called,
there is no client connection information yet, so the parameter wsi
still pointing to the main server connection. Add an description of
this behavior to the documentation.
2014-02-15 14:02:30 +08:00