platform/upstream/libwebsockets.git
10 years agofix visibility of return_http_status
Andy Green [Fri, 21 Feb 2014 10:51:38 +0000 (18:51 +0800)]
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>
10 years agofix WITHOUT_CLIENT install in CMake
Andy Green [Fri, 21 Feb 2014 10:48:05 +0000 (18:48 +0800)]
fix WITHOUT_CLIENT install in CMake

Via "DevYourWorld" on github

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

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agoupdate cmake opts in README.build
Andy Green [Fri, 21 Feb 2014 10:45:45 +0000 (18:45 +0800)]
update cmake opts in README.build

via "DevYourWorld" on github

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

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agointerface_to_sa no longer server only
Andy Green [Fri, 21 Feb 2014 10:43:42 +0000 (18:43 +0800)]
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>
10 years agoCall libwebsocket_set_timeout() before callback LWS_CALLBACK_HTTP.
Craig McQueen [Wed, 19 Feb 2014 23:27:11 +0000 (10:27 +1100)]
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.

10 years agoAdd support to binding client to interface.
Mattias Lundberg [Tue, 18 Feb 2014 09:06:57 +0000 (10:06 +0100)]
Add support to binding client to interface.

10 years agoFix compilation on Windows.
Joakim Soderberg [Tue, 18 Feb 2014 12:38:14 +0000 (13:38 +0100)]
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.

10 years agoAdd LWS_VISIBLE to libwebsocket_set_timeout() so it can be used externally.
Craig McQueen [Tue, 18 Feb 2014 22:24:17 +0000 (09:24 +1100)]
Add LWS_VISIBLE to libwebsocket_set_timeout() so it can be used externally.

10 years agoadd missing CMake pieces
Andy Green [Sat, 15 Feb 2014 17:52:50 +0000 (01:52 +0800)]
add missing CMake pieces

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agodocument new extpoll apis
Michael Haberler [Sat, 15 Feb 2014 12:33:46 +0000 (20:33 +0800)]
document new extpoll apis

10 years agoupdate test server for new extpoll
Michael Haberler [Sat, 15 Feb 2014 12:21:02 +0000 (20:21 +0800)]
update test server for new extpoll

10 years agochange extpoll in lib to new way
Michael Haberler [Sat, 15 Feb 2014 12:19:26 +0000 (20:19 +0800)]
change extpoll in lib to new way

10 years agoreplace old extpoll callbacks with LWS_CALLBACK_CHANGE_MODE_POLL_FD
Michael Haberler [Sat, 15 Feb 2014 12:18:24 +0000 (20:18 +0800)]
replace old extpoll callbacks with LWS_CALLBACK_CHANGE_MODE_POLL_FD

10 years agodefine struct libwebsocket_pollargs
Michael Haberler [Sat, 15 Feb 2014 12:15:55 +0000 (20:15 +0800)]
define struct libwebsocket_pollargs

10 years agoadd outermost wsi lifetime callbacks
Andy Green [Sat, 15 Feb 2014 11:25:50 +0000 (19:25 +0800)]
add outermost wsi lifetime callbacks

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agoLWS_CALLBACK_USER
Andy Green [Sat, 15 Feb 2014 08:49:41 +0000 (16:49 +0800)]
LWS_CALLBACK_USER

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agolibwebsocket_callback_all_protocol
Andy Green [Sat, 15 Feb 2014 08:36:38 +0000 (16:36 +0800)]
libwebsocket_callback_all_protocol

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agoadd const http write helper
Gabriel Gritsch [Sat, 15 Feb 2014 08:20:25 +0000 (16:20 +0800)]
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

10 years agofix zero length ping pong
Andy Green [Sat, 15 Feb 2014 08:00:37 +0000 (16:00 +0800)]
fix zero length ping pong

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agomissing endian preprocessor defines on Linux environments
Daniel Ludwig [Thu, 13 Feb 2014 23:17:46 +0000 (00:17 +0100)]
missing endian preprocessor defines on Linux environments

10 years agoupdate version in libwebsockets.pc
Andy Green [Sat, 15 Feb 2014 06:45:14 +0000 (14:45 +0800)]
update version in libwebsockets.pc

Signed-off-by: Andy Green <andy.green@linaro.org>
10 years agofix memory leak
arnaudviala [Sat, 15 Feb 2014 06:39:40 +0000 (14:39 +0800)]
fix memory leak

Fix a possible memory leak in
 libwebsocket_context_destroy() when compiled without extension support.

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

10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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.

10 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>
10 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.

10 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.

10 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.

10 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.

10 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>
10 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>
10 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>
10 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>
10 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>
10 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.

10 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.

10 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.

10 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.

10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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