platform/upstream/libwebsockets.git
10 years agoadd timeout between accept and negotiation
Andy Green [Sat, 15 Feb 2014 06:36:02 +0000 (14:36 +0800)]
add timeout between accept and negotiation

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agoFix documentation for LWS_CALLBACK_FILTER_NETWORK_CONNECTION
Alexandre Erwin Ittner [Fri, 7 Feb 2014 01:15:51 +0000 (23:15 -0200)]
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.

10 years agomake force_exit volatile.
Jakob Flierl [Mon, 27 Jan 2014 11:37:47 +0000 (12:37 +0100)]
make force_exit volatile.

Instruct the compiler to always access force_exit in memory.

10 years agocmake and other fixes
Joakim Soderberg [Sat, 15 Feb 2014 05:48:56 +0000 (13:48 +0800)]
cmake and other fixes

10 years agoRemoved needless VS projects now that cmake is fixed
martell [Wed, 22 Jan 2014 19:01:14 +0000 (19:01 +0000)]
Removed needless VS projects now that cmake is fixed

10 years agoadditional mingw fixes
martell [Sat, 15 Feb 2014 05:37:08 +0000 (13:37 +0800)]
additional mingw fixes

Signed-off-by: martell <martellmalone@gmail.com>
10 years agofixed windows build
martell [Wed, 22 Jan 2014 18:17:03 +0000 (18:17 +0000)]
fixed windows build

10 years agotrac 53 mingw ssize_t redef
Andy Green [Sat, 15 Feb 2014 04:46:33 +0000 (12:46 +0800)]
trac 53 mingw ssize_t redef

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agofix LWS_NO_SERVER compile
John Clark [Sun, 9 Feb 2014 23:24:29 +0000 (07:24 +0800)]
fix LWS_NO_SERVER compile

Signed-off-by: John Clark <inidev@gmail.com>
10 years agoSubject: [PATCH] libwebsockets.h: use _GNU_SOURCE instead of __USE_GNU
Michael Haberler [Fri, 10 Jan 2014 22:40:14 +0000 (23:40 +0100)]
Subject: [PATCH] libwebsockets.h: use _GNU_SOURCE instead of __USE_GNU

this collides with use of features.h which says '#define __USE_GNU 1'

see also second answer:
http://stackoverflow.com/questions/7296963/gnu-source-and-use-gnu?answertab=active#tab-top

10 years agofix lws_lookup off by one
nononame [Sat, 11 Jan 2014 05:12:34 +0000 (13:12 +0800)]
fix lws_lookup off by one

Signed-off-by: nononame <nononame@le-huit.fr>
10 years agoppoll fix signal mask sense
Andy Green [Sat, 11 Jan 2014 04:37:07 +0000 (12:37 +0800)]
ppoll fix signal mask sense

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agoUse ppoll to allow signals to wake service loop early on change of pollfd event
Andy Green [Wed, 25 Dec 2013 08:34:37 +0000 (16:34 +0800)]
Use ppoll to allow signals to wake service loop early on change of pollfd event

To enable this code you need to force LWS_HAS_PPOLL to de defined.

#defining it at the top of libwebsockets.c is enough.

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agounify all pollfd lock management
Andy Green [Sat, 21 Dec 2013 03:18:34 +0000 (11:18 +0800)]
unify all pollfd lock management

This provides a single place for pollfd event changing,
external locking for that and extpoll management.

It saves about 85 lines of duplication and simplifies the callers.

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agoopenwrt add build makefile
tmu [Sat, 21 Dec 2013 02:33:33 +0000 (10:33 +0800)]
openwrt add build makefile

http://libwebsockets.org/trac/libwebsockets/ticket/50

Signed-off-by: tmu <tmu-INVALID@invalid.com>
10 years agofix dropmask dereference even when NULL
Nikolay Dimitrov [Sat, 21 Dec 2013 02:22:17 +0000 (10:22 +0800)]
fix dropmask dereference even when NULL

Signed-off-by: Nikolay Dimitrov <ndimitrov@setelis.com>
10 years agoTrac 53 minw update
pmcdona [Wed, 18 Dec 2013 02:17:25 +0000 (10:17 +0800)]
Trac 53 minw update

http://libwebsockets.org/trac/libwebsockets/ticket/53

10 years agoadd locking callback for fds
Andy Green [Wed, 18 Dec 2013 01:48:26 +0000 (09:48 +0800)]
add locking callback for fds

This adds two new callbacks in protocols[0] that are optional for allowing limited thread
access to libwebsockets, LWS_CALLBACK_LOCK_POLL and LWS_CALLBACK_UNLOCK_POLL.

If you use them, they protect internal and external poll list changes, but if you want to use
external thread access to libwebsocket_callback_on_writable() you have to implement your
locking here even if you don't use external poll support.

If you will use another thread for this, take a lot of care about managing your list of
live wsi by doing it from ESTABLISHED and CLOSED callbacks (with your own locking).

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agoOptionally allow non-SSL connections on same port as SSL
James Devine [Sat, 14 Dec 2013 03:41:29 +0000 (11:41 +0800)]
Optionally allow non-SSL connections on same port as SSL

If enabled one listening socket will accept both SSL and plain HTTP connections.

Do not enable if you regard SSL handshake as some kind of security, eg, use
client-side certs to restrict access.

AG: changed flag names, added extra comments, changelog, add -a in test server

Signed-off-by: James Devine <fxmulder@gmail.com>
Signed-off-by: Andy Green <andy@warmcat.com>
10 years agowindows use msvc baestd and ssize_t from there
James Chen [Sat, 14 Dec 2013 03:35:01 +0000 (11:35 +0800)]
windows use msvc baestd and ssize_t from there

Signed-off-by: James Chen <jianhua.chen@cocos2d-x.org>
10 years agodistinguish error from truncation
Christian Wyss [Tue, 10 Dec 2013 13:34:30 +0000 (21:34 +0800)]
distinguish error from truncation

Signed-off-by: Christian Wyss <christian.wyss@gfk.com>
10 years agoie10 lws url workaround
John Harrison [Tue, 10 Dec 2013 13:20:03 +0000 (21:20 +0800)]
ie10 lws url workaround

Signed-off-by: John Harrison <john@h-agtec.com>
10 years agoNO_EXTENSIONS fixes
mroszko [Tue, 10 Dec 2013 13:15:00 +0000 (21:15 +0800)]
NO_EXTENSIONS fixes

Trac #52

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agohandle EAGAIN during send
Andy Green [Mon, 9 Dec 2013 06:16:17 +0000 (14:16 +0800)]
handle EAGAIN during send

This patch deploys the truncated send work to buffer output in case
either send() or the SSL send return a temporary "unable to send"
condition even though they signalled as writeable.

I added a by-default #if 0 test jig which enforces only half of what
you want to send is sendable, this is working when enabled.

One subtle change is that the pipe reports choked if there is any
pending remaining truncated send.  Otherwise it should be transparent.

Hopefully...

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agosolve broken partial file sends
Andy Green [Mon, 9 Dec 2013 03:27:07 +0000 (11:27 +0800)]
solve broken partial file sends

We can't force the wsi state to HTTP_BODY without considering the callback
may already have set the state to sending a file.

This fixes the bug that we can get stalled in the test app at
"choked before able to send whole file"

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agointerpret zero rx buffer size as default in http
Andy Green [Sun, 8 Dec 2013 13:26:52 +0000 (21:26 +0800)]
interpret zero rx buffer size as default in http

Reported by pystub

https://github.com/warmcat/libwebsockets/pull/33#issuecomment-29578258

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agoprotect the label with an ifdef
Andreas Pakulat [Mon, 4 Nov 2013 11:51:50 +0000 (12:51 +0100)]
protect the label with an ifdef

The only part that actually goes to this label is inside such an ifdef,
so building without extension support makes gcc bail out since an unused
label is considered an error in this project.

10 years agoSubject: [PATCH] Fixed the logging of OpenSSL errors to report the correct
Jonti [Fri, 22 Nov 2013 11:14:26 +0000 (13:14 +0200)]
Subject: [PATCH] Fixed the logging of OpenSSL errors to report the correct
 details for the current OpenSSL error

10 years agoSupport for HTTP POST.
kapejod [Tue, 19 Nov 2013 12:38:16 +0000 (13:38 +0100)]
Support for HTTP POST.
Rewritten by Andy Green to use chunks, add timeout, use extra states in handshake not parser.

Signed-off-by: Andy Green <andy@warmcat.com>
10 years agosupport for client authentication based on certs
prasannateamf1 [Wed, 13 Nov 2013 01:21:01 +0000 (17:21 -0800)]
support for client authentication based on certs

11 years agocase insensitive http headers
Andy Green [Wed, 13 Nov 2013 00:03:05 +0000 (08:03 +0800)]
case insensitive http headers

Svetlin wrote on github

According to RFC2616, all header field names in both HTTP requests and HTTP responses are case-insensitive. But libwebsockets uses a case-sensitive compare.

Reproduce:
Run libwebsockets against a server that sends all of its HTTP header field names in lower-case (for example: https://github.com/extend/cowboy). libwebsockets reports an error. The expected behavior is no errors reported and a successful handshake procedure.

This changes the parser reference table in minilex to all lower case.

The code to walk the parser tables then just forces a tolower on the incoming chars.

This (and minilex tables) only applies to header names.

Reported-by: svetlin-mladnov <?@github>
Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agointroduce uri args
Andy Green [Tue, 12 Nov 2013 23:45:17 +0000 (07:45 +0800)]
introduce uri args

If the URI coming from the client contains '?' then

 - the URI part is terminated with a '\0'

 - the remainder of the URI goes in a new header WSI_TOKEN_HTTP_URI_ARGS

 - the remainder of the URI is not subject to path sanitization measures (it
    still has %xx processing done on it)

In the test server, http requests now also dump header information to stderr.

The attack.sh script is simplified and can now parse the test server header dumps.

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoback up directory paths properly
Andy Green [Tue, 12 Nov 2013 22:53:21 +0000 (06:53 +0800)]
back up directory paths properly

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoreal http status codes update attack.sh
Andy Green [Sun, 10 Nov 2013 23:30:33 +0000 (07:30 +0800)]
real http status codes update attack.sh

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agouri santitation fixes deal with single dot update attack.sh
Andy Green [Sun, 10 Nov 2013 22:14:52 +0000 (06:14 +0800)]
uri santitation fixes deal with single dot update attack.sh

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotranslate and protect uri test sever use uri path
Andy Green [Sun, 10 Nov 2013 07:15:21 +0000 (15:15 +0800)]
translate and protect uri test sever use uri path

This translates %xx in the GET uri and removes /.. and /... type sequences along with
translating // or /// etc to /.

Since the result is hopefully secure, it also changes the test server to actually use
the uri path pasted on a resource directory without whitelisting.

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agointroduce LWS_CALLBACK_FILTER_HTTP_CONNECTION
Andy Green [Sat, 9 Nov 2013 03:59:56 +0000 (11:59 +0800)]
introduce LWS_CALLBACK_FILTER_HTTP_CONNECTION

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoadd cookie example to test server
Andy Green [Sat, 9 Nov 2013 03:06:29 +0000 (11:06 +0800)]
add cookie example to test server

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoallow other headers in http send file
Andy Green [Sat, 9 Nov 2013 03:04:35 +0000 (11:04 +0800)]
allow other headers in http send file

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agomake ah available in http callback properly
Andy Green [Sat, 9 Nov 2013 03:40:32 +0000 (11:40 +0800)]
make ah available in http callback properly

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoimprove minilex use external parsing header
Andy Green [Sat, 9 Nov 2013 02:09:09 +0000 (10:09 +0800)]
improve minilex use external parsing header

Clean up minilex
Move the header output to stdout
Introduce lexfile.h as the header output
Use lexfile.h in both minilex itself and lws
Add the following header support

       "Accept:",
       "If-Modified-Since:",
       "Accept-Encoding:",
       "Accept-Language:",
       "Pragma:",
       "Cache-Control:",
       "Authorization:",
       "Cookie:",
       "Content-Type:",
       "Date:",
       "Range:",
       "Referer:"

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agowindows workaround unsigned fd in emulated poll
Graham Newton [Sat, 9 Nov 2013 00:11:41 +0000 (08:11 +0800)]
windows workaround unsigned fd in emulated poll

A common practise to temporarily disable a socket in a poll call is to negate the socket fd.  poll should then ignore the socket.
emulated_poll does this with the following code:
        if (poll_fd->fd < 0 || !poll_fd->events)
            goto skip1;

However on Windows the fd field in WSAPOLLFD is unsigned int!!!  So the check for a negative fd value always fails.
This results in select returning an error with an error code of 10038 -- Socket operation on nonsocket.
The fix is to type cast fd like so:
        if ((int)poll_fd->fd < 0 || !poll_fd->events)

This may be the cause of some high CPU load reports.  I noticed the load being 50% with my application running on Windows XP.

Signed-off-by: Graham Newton <gnewton@peavey-eu.com>
11 years agointerface improve visibility fail if not found
Andy Green [Sat, 9 Nov 2013 00:07:38 +0000 (08:07 +0800)]
interface improve visibility fail if not found

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoWindows Fix usage in Windows XP targetting projects
Andreas Pakulat [Mon, 28 Oct 2013 14:00:16 +0000 (15:00 +0100)]
Windows Fix usage in Windows XP targetting projects

This is important since this stuff is in publicly included headers
and even though the usage of the WSAPoll API is a runtime decision
the public headers may be used in code that needs to build with
_WIN32_WINNT=0x0501 to support WinXP.

When building a project using libwebsockets with that define set
to 0x0501 winsock.h will not define the WSAPOLLFD struct causing that
project to fail to compile.

11 years agounixify websock w32.h line endings
Andy Green [Mon, 4 Nov 2013 02:17:50 +0000 (10:17 +0800)]
unixify websock w32.h line endings

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoWindows Fix include for win32helpers
Andreas Pakulat [Wed, 16 Oct 2013 15:57:17 +0000 (17:57 +0200)]
Windows Fix include for win32helpers

The installed headers are all in the same directory, so no relative
path possible there. The cmake files already add the win32helpers
directory to the include paths, so this builds just fine.

11 years agoWindows Fix installing the dll
Andreas Pakulat [Mon, 28 Oct 2013 15:02:12 +0000 (16:02 +0100)]
Windows Fix installing the dll

Without a runtime install directory, cmake won't install the dll at
all. Only the import library was installed. So fix that.

11 years agoSupport _WIN32 in addition to WIN32 define
Andreas Pakulat [Mon, 28 Oct 2013 14:18:04 +0000 (15:18 +0100)]
Support _WIN32 in addition to WIN32 define

MSVC8 and MSVC9 set only _WIN32, so support that define as well to be able
to compile libwebsockets with those compilers.

11 years agoDrop wsockcompat.h header its not part of msvc
Andreas Pakulat [Mon, 28 Oct 2013 14:15:44 +0000 (15:15 +0100)]
Drop wsockcompat.h header its not part of msvc

I don't see a wsockcompat.h anywhere in MSVC9 or MSVC8 and their
corresponding sdk's. It does not seem like this is a standard windows
header, so better drop that and add the compat-defines to the same
place that already has other WSA compat defines.

11 years agohandle HUP on any mode socket
Graham Newton [Mon, 4 Nov 2013 01:47:06 +0000 (09:47 +0800)]
handle HUP on any mode socket

I am using libwebsockets on Windows 7 in external poll mode.
I am finding that if I present a socket fd on a normal HTTP connection
(LWS_CONNMODE_HTTP_SERVING:) to libwebsocket_service_fd with just a HUP
event, the event doesn't get handled but revents gets cleared indicating
that the event has been handled.  Should it be handled in the same way
as LWS_CONNMODE_WS_SERVING?

(Modified by AG to apply to all sockets)

Signed-off-by: Andy Green <andy.green@linaro.org>
Signed-off-by: Graham Newton <gnewton@peavey-eu.com>
11 years agotrac41 WIN32 add wsockcompat.h
Andy Green [Sat, 26 Oct 2013 13:18:44 +0000 (21:18 +0800)]
trac41 WIN32 add wsockcompat.h

Using Windows 7 64 bit, cloned repo on 20130926. Using Qt creator and Microsoft Visual C++ Compiler 9.0 (x86).
Result (errors from compile output): D:\Projects\CDPStudioAPI\libwebsockets_orig\lib\client-handshake.c:87: error: C2065: 'EALREADY' : undeclared identifier
D:\Projects\CDPStudioAPI\libwebsockets_orig\lib\client-handshake.c:87: error: C2065: 'EINPROGRESS' : undeclared identifier
Possible solution is to use wsockcompat.h (compatibility header for using EALREADY, EINPROGRESS etc in older versions of Windows SDK). Compiled fine when I #included wsockcompat.h into client-handshake.c

Reported-by: mart22n via Trac 41
Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agov1.2.3 changelog update
Andy Green [Sat, 26 Oct 2013 12:36:08 +0000 (20:36 +0800)]
v1.2.3 changelog update

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agomake header protection unique remove __prefix
Markus Elfring [Sat, 26 Oct 2013 12:23:00 +0000 (20:23 +0800)]
make header protection unique remove __prefix

Signed-off-by: Markus Elfring <markus.elfring@web.de>
11 years agofix cmake quoting
Markus Elfring [Sat, 26 Oct 2013 12:03:43 +0000 (20:03 +0800)]
fix cmake quoting

A few parameters (like "${PROJECT_BINARY_DIR}/lws_config.h" and "${PROJECT_SOURCE_DIR}/lib") are passed to CMake commands in your build script without enclosing them by quotation marks. I see that these places will result in build difficulties if the contents of the used variables will contain special characters like spaces.

Signed-off-by: Markus Elfring <markus.elfring@web.de>
11 years agocover-proxy-read-EAGAIN.patch
shys [Fri, 25 Oct 2013 13:50:21 +0000 (15:50 +0200)]
cover-proxy-read-EAGAIN.patch
Subject: [PATCH] Because of nonblocking sockets reading from  proxy might not
 work in one turn. We should check for EAGAIN.

11 years agoSubject: [PATCH] Additional check for EISONN. On iOS "if (connect()) == -1 ||
shys [Fri, 25 Oct 2013 13:49:11 +0000 (15:49 +0200)]
Subject: [PATCH] Additional check for EISONN. On iOS "if (connect()) == -1 ||
 errno == EISCONN)" doesn't work.

11 years agoSubject: [PATCH] On iOS with nonblocking sockets I experience SSL error which
shys [Fri, 25 Oct 2013 13:52:47 +0000 (15:52 +0200)]
Subject: [PATCH] On iOS with nonblocking sockets I experience SSL error which
 is not really an error (
 http://lists.freeradius.org/pipermail/freeradius-users/2009-August/040155.html
 ). Added check for that. Additional fixes for comments and logging.

11 years agofix origin
u0u0 [Fri, 25 Oct 2013 09:13:11 +0000 (17:13 +0800)]
fix origin

And fix client header of Origin, add prefix "http://" to make a valid URI, to make golang websocket server happy.

11 years agodefer changing to proxy uri until connected
Andy Green [Fri, 25 Oct 2013 14:07:57 +0000 (22:07 +0800)]
defer changing to proxy uri until connected

Reported-by: shyswork
Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoadd EISCONN handling to client connect attempt
Andy Green [Thu, 24 Oct 2013 14:07:04 +0000 (22:07 +0800)]
add EISCONN handling to client connect attempt

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agowait ssl connect completion on client proxy path
shys [Thu, 24 Oct 2013 14:27:08 +0000 (22:27 +0800)]
wait ssl connect completion on client proxy path

Subject: [PATCH] We can ran into situation (at least on iOS) when with openssl
 nonblocking BIO and http proxy we don't perform ssl_connect straight away so
 we need to retry until we finish ssl_connect. If we don't do that we will
 fail in LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY when testing for "HTTP/1.0
 200" successful connection.

Signed-off-by: shys <shyswork@zoho.com>
11 years agomanual proxy forcing api
shys [Thu, 24 Oct 2013 14:12:03 +0000 (22:12 +0800)]
manual proxy forcing api

add function to manually setup proxy. Useful on iOS where
 getenv doesn't return proxy settings

Simplified by AG

Signed-off-by: shys <shyswork@zoho.com>
Signed-off-by: Andy Green <andy@warmcat.com>
11 years agoCMAKE help if cwd not git dir
Arokux X [Thu, 24 Oct 2013 13:53:39 +0000 (21:53 +0800)]
CMAKE help if cwd not git dir

Hi all,

please consider applying the patch below. The git is called in some
different directory and that is why fails. I'm not sure why it was
called in different directory, maybe because I build libwebsockets
with CMake's ExternalProject.

Best,
Arokux

Signed-off-by: Arokux X <arokux@gmail.com>
11 years agofix typo in NO_SERVER case
Andy Green [Thu, 24 Oct 2013 13:47:06 +0000 (21:47 +0800)]
fix typo in NO_SERVER case

Reported-by: shyswork via github
Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agouse compatible_close for sockets
Andy Green [Mon, 21 Oct 2013 22:49:30 +0000 (06:49 +0800)]
use compatible_close for sockets

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agofix clean return path user code handle
Andy Green [Fri, 18 Oct 2013 11:23:06 +0000 (19:23 +0800)]
fix clean return path user code handle

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoadd explicit error for partial send
Andy Green [Thu, 17 Oct 2013 00:09:19 +0000 (08:09 +0800)]
add explicit error for partial send

This patch adds code to handle the situation that a prepared user buffer could not all be sent on the
socket at once.  There are two kinds of situation to handle

1) User code handles it: The connection only has extensions active that do not rewrite the buffer.
In this case, the patch caused libwebsocket_write() to simply return the amount of user buffer that
was consumed (this is specifically the amount of user buffer used in sending what was accepted,
nothing else).  So user code can just advance its buffer that much and resume sending when the socket
is writable again.  This continues the frame rather than starting a new one or new fragment.

2) The connections has extensions active which actually send something quite different than what the
user buffer contains, for example a compression extension.  In this case, libwebsockets will dynamically
malloc a buffer to contain a copy of the remaining unsent data, request notifiction when writeable again,
and automatically spill and free this buffer with the highest priority before passing on the writable
notification to anything else.  For this situation, the call to write will return that it used the
whole user buffer, even though part is still rebuffered.

This patch should enable libwebsockets to detect the two cases and take the appropriate action.

There are also two choices for user code to deal with partial sends.

1) Leave the no_buffer_all_partial_tx member in the protocol struct at zero.  The library will dyamically
buffer anything you send that did not get completely written to the socket, and automatically spill it next
time the socket is writable.  You can use this method if your sent frames are relatvely small and unlikely to get
truncated anyway.

2) Set the no_buffer_all_partial_tx member in the protocol struct.  User code now needs to take care of the
return value from libwebsocket_write() and deal with resending the remainder if not all of the requested amount
got sent.  You should use this method if you are sending large messages and want to maximize throughput and efficiency.

Since the new member no_buffer_all_partial_tx will be zero by default, this patch will auto-rebuffer any
partial sends by default.  That's good for most cases but if you attempt to send large blocks, make sure you
follow option 2) above.

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac 40 client connection properly nonblocking
Andy Green [Fri, 20 Sep 2013 12:26:12 +0000 (20:26 +0800)]
trac 40 client connection properly nonblocking

As spotted by JM on Trac#40

http://libwebsockets.org/trac/libwebsockets/ticket/40

client connect didn't do anything about being truly nonblocking.  This patch
should hopefully solve that.

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoforce failed header parse to act
Fujii Bunichiroh [Wed, 18 Sep 2013 13:01:02 +0000 (21:01 +0800)]
force failed header parse to act

''...Websocket servers return failure responses other than HTTP Status 101 in the case of
mismatches of WebSocket version or additional header data etc...
It seems that libwebsockets shows "WARN: problems parsing header" error in such cases without
calling any callbacks or returning error code. Is this right?
I modified lib/client.c to handle this.''

Signed-off-by: Fujii Bunichiroh <Bunichiroh.Fujii@jp.sony.com>
11 years agoremove bae64 decode and selftest
Andy Green [Wed, 18 Sep 2013 12:57:59 +0000 (20:57 +0800)]
remove bae64 decode and selftest

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac #39: allow fd 0 for connection
Andy Green [Wed, 18 Sep 2013 04:59:33 +0000 (12:59 +0800)]
trac #39: allow fd 0 for connection

Reported (with fix) by Martijn The http://libwebsockets.org/trac/ticket/39

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agocmake fix for osx 64 bit
Erland Isaksson [Wed, 18 Sep 2013 01:00:52 +0000 (09:00 +0800)]
cmake fix for osx 64 bit

AG tested on 64-bit Fedora no problems

Signed-off-by: Erland Isaksson <erland@isaksson.info>
11 years agotrac 36 make libwebsocket_set_timeout public
Andy Green [Wed, 18 Sep 2013 00:47:15 +0000 (08:47 +0800)]
trac 36 make libwebsocket_set_timeout public

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agochange LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION user param usage
Andy Green [Wed, 18 Sep 2013 00:32:55 +0000 (08:32 +0800)]
change LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION user param usage

Also audit the bail_nuke_ah usage as Daniel Griscom suggested.

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agofix http incomplete send handling
David Gauchard [Sat, 29 Jun 2013 02:24:16 +0000 (10:24 +0800)]
fix http incomplete send handling

Signed-off-by: David Gauchard <gauchard@laas.fr>
11 years agoRequest "send" not to trigger SIGPIPE on errors.
Joachim Bauch [Sat, 29 Jun 2013 02:22:09 +0000 (10:22 +0800)]
Request "send" not to trigger SIGPIPE on errors.

11 years agoadd CMake find function for libwebsockets
Jiri Hnidek [Sat, 29 Jun 2013 02:18:52 +0000 (10:18 +0800)]
add CMake find function for libwebsockets

Signed-off-by: Jiri Hnidek <jiri.hnidek@tul.cz>
11 years agoAdded additional LWS_CALLBACK_CLOSED_HTTP callback to just_kill_connection branch...
Niall T. Davidson [Sat, 29 Jun 2013 02:16:18 +0000 (10:16 +0800)]
Added additional LWS_CALLBACK_CLOSED_HTTP callback to just_kill_connection branch of close_and_free_session

11 years agoSupport empty ping and pong packets.
Joachim Bauch [Sun, 23 Jun 2013 06:47:26 +0000 (14:47 +0800)]
Support empty ping and pong packets.

11 years agoDeclare "sha1_init" statically to avoid naming conflicts if linked statically with...
Joachim Bauch [Wed, 19 Jun 2013 13:10:26 +0000 (15:10 +0200)]
Declare "sha1_init" statically to avoid naming conflicts if linked statically with other libraries providing a method with the same name (e.g. OpenSSL).

11 years agoadd LWS_CALLBACK_CLOSED_HTTP
Andy Green [Mon, 10 Jun 2013 14:54:40 +0000 (22:54 +0800)]
add LWS_CALLBACK_CLOSED_HTTP

Adds a callback to allow handling HTTP protocol connections
closing.

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac 28 - differentiate between http serving and accepted http connection
Andy Green [Sun, 19 May 2013 06:04:10 +0000 (14:04 +0800)]
trac 28 - differentiate between http serving and accepted http connection

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac 28 brackets around POLLIN flag test
Simon Wulf [Sun, 5 May 2013 22:11:53 +0000 (06:11 +0800)]
trac 28 brackets around POLLIN flag test

Signed-off-by: Simon Wulf <simonwulf.lund@bredband.net>
11 years agolog err if unable to open http file
Andy Green [Fri, 3 May 2013 13:13:35 +0000 (21:13 +0800)]
log err if unable to open http file

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac 29 convert more snprintf stowaways
Andy Green [Thu, 2 May 2013 00:15:53 +0000 (08:15 +0800)]
trac 29 convert more snprintf stowaways

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac 29 echo remoe mention of syslog constants for win32
Andy Green [Wed, 1 May 2013 23:04:54 +0000 (07:04 +0800)]
trac 29 echo remoe mention of syslog constants for win32

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac 29 avoid syslog in echo test if win32
Andy Green [Mon, 29 Apr 2013 22:53:56 +0000 (06:53 +0800)]
trac 29 avoid syslog in echo test if win32

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac 29 eliminate snprintf again
Andy Green [Mon, 29 Apr 2013 22:51:10 +0000 (06:51 +0800)]
trac 29 eliminate snprintf again

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotrac 29 win32 EWOULDBLOCK
Andy Green [Sat, 27 Apr 2013 00:33:26 +0000 (08:33 +0800)]
trac 29 win32 EWOULDBLOCK

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoTrac 29: win32 fix LWS_VISIBLE issue
Andy Green [Thu, 25 Apr 2013 23:37:16 +0000 (07:37 +0800)]
Trac 29: win32 fix LWS_VISIBLE issue

Reported-by: davetaflin
Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agocygwin compatibility
Bob Roberts [Thu, 25 Apr 2013 01:16:30 +0000 (09:16 +0800)]
cygwin compatibility

Signed-off-by: Bob Roberts <bobroberts177@gmail.com>
11 years agotrac 27: use fullpath in OSX dynamic libs
thinkski [Tue, 16 Apr 2013 11:48:05 +0000 (19:48 +0800)]
trac 27: use fullpath in OSX dynamic libs

Signed-off-by: thinkski <chiszp@gmail.com>
11 years agopkg config avoid hardcoded prefix
thinkski [Fri, 12 Apr 2013 02:31:46 +0000 (10:31 +0800)]
pkg config avoid hardcoded prefix

Signed-off-by: thinkski <chiszp@gmail.com>
11 years agocmake use existing spec file for RPM generation
Tomas Cejka [Thu, 11 Apr 2013 00:13:13 +0000 (08:13 +0800)]
cmake use existing spec file for RPM generation

Signed-off-by: Tomas Cejka <cejkat@cesnet.cz>
11 years agocmake added RPM generation
Tomas Cejka [Thu, 11 Apr 2013 00:38:02 +0000 (08:38 +0800)]
cmake added RPM generation

Signed-off-by: Tomas Cejka <cejkat@cesnet.cz>
11 years agocmake improve cross documentation
Andy Green [Sat, 30 Mar 2013 02:30:03 +0000 (10:30 +0800)]
cmake improve cross documentation

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agoHide private library symbols
Peter Pentchev [Sat, 30 Mar 2013 01:52:21 +0000 (09:52 +0800)]
Hide private library symbols

Signed-off-by: Peter Pentchev <roam@ringlet.net>
11 years agoSOL_SNDBUF set to protocol rx size
Andy Green [Sat, 23 Mar 2013 01:53:17 +0000 (09:53 +0800)]
SOL_SNDBUF set to protocol rx size

This tells the OS to reserve a TX buffer at least the size of the biggest RX frame
expected, for both server and client connections.

In Linux, the OS reserves 2 x the requested amount.

This is aimed at reducing the partial large atomic frame send problem to the point
it's only coming at large atomic frames the OS balks at reserving the size for.

If you have a lot of data to send, it is better to split it into multiple writes,
and use the FIN / CONTINUATION websocket stuff to manage it.

See the "fraggle" test app for example code of how to do that.

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agotest server improve return checking
Andy Green [Sat, 23 Mar 2013 01:46:18 +0000 (09:46 +0800)]
test server improve return checking

Signed-off-by: Andy Green <andy.green@linaro.org>
11 years agocosmetic debug improvements
Andy Green [Sat, 23 Mar 2013 01:44:47 +0000 (09:44 +0800)]
cosmetic debug improvements

Signed-off-by: Andy Green <andy.green@linaro.org>