Commit graph

1170 commits

Author SHA1 Message Date
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
martell
19c73f3bed fixed windows build 2014-02-15 13:34:25 +08:00
Andy Green
ac1ebba564 trac 53 mingw ssize_t redef
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-02-15 12:46:33 +08:00
John Clark
9bdcf18e74 fix LWS_NO_SERVER compile
Signed-off-by: John Clark <inidev@gmail.com>
2014-02-10 07:24:29 +08:00
Michael Haberler
eca0e4913d 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
2014-01-18 11:44:50 +08:00
nononame
f162492cf3 fix lws_lookup off by one
Signed-off-by: nononame <nononame@le-huit.fr>
2014-01-11 13:12:34 +08:00
Andy Green
ed451d5cbf ppoll fix signal mask sense
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-01-11 12:37:07 +08:00
Andy Green
3b3fa9e208 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>
2013-12-25 16:34:37 +08:00
Andy Green
91f19d8d79 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>
2013-12-21 11:18:34 +08:00
Nikolay Dimitrov
a8268e7619 fix dropmask dereference even when NULL
Signed-off-by: Nikolay Dimitrov <ndimitrov@setelis.com>
2013-12-21 10:22:17 +08:00
pmcdona
0a0a7ebc37 Trac 53 minw update
http://libwebsockets.org/trac/libwebsockets/ticket/53
2013-12-18 10:17:25 +08:00
Andy Green
7a1327977a 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>
2013-12-18 09:48:26 +08:00
James Devine
5b34c975ae 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>
2013-12-14 11:41:29 +08:00
James Chen
4ebedc2c30 windows use msvc baestd and ssize_t from there
Signed-off-by: James Chen <jianhua.chen@cocos2d-x.org>
2013-12-14 11:35:01 +08:00
mroszko
793e7c07d8 NO_EXTENSIONS fixes
Trac #52

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-12-10 21:15:00 +08:00
Andy Green
2764eba89f 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>
2013-12-09 14:16:17 +08:00
Andy Green
aa08492021 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>
2013-12-09 11:27:07 +08:00
Andy Green
ca15338545 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>
2013-12-08 21:26:52 +08:00