diff --git a/CHANGELOG.md b/CHANGELOG.md index cc21e310..9525551b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,19 @@ unreleased ========== +version 1.3.1 +============= + +Released 2017-06-02 + +## Fixed + +- configure script can handle relative path to source, when invoked + +- using case-insensitive string comparison when processing HTTP headers + +- examples now are built statically + version 1.3 =========== diff --git a/config.h.cmake b/config.h.cmake index 9e10a366..7a6e3e95 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -63,7 +63,7 @@ #define PACKAGE_NAME "wampcc" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "wampcc 1.1.1" +#define PACKAGE_STRING "wampcc 1.3.1" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "wampcc" @@ -72,8 +72,7 @@ #define PACKAGE_URL " " /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.1.1" +#define PACKAGE_VERSION "1.3.1" #endif - diff --git a/configure.ac b/configure.ac index e6a9d3ac..54a3852d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ #========== Initialisation ========== -AC_INIT([wampcc], [1.3], [wampcc@darrenjs.net], [wampcc], [ ] ) +AC_INIT([wampcc], [1.3.1], [wampcc@darrenjs.net], [wampcc], [ ] ) AC_PREREQ([2.59]) AC_CONFIG_AUX_DIR([.]) @@ -83,10 +83,16 @@ AC_HEADER_STDBOOL AC_C_CONST AC_C_INLINE +# The user provided 'srcdir' might be a relative or an absolute path, depending +# on how the configure script was invoked. Here we obtain the absolute path to +# the srcdir. +wampcc_src_dir=`(cd "$srcdir"; pwd)` -# log some directories know to configure +# log some directories known to configure AC_MSG_NOTICE([notice srcdir: ${srcdir}]) AC_MSG_NOTICE([notice prefix: ${prefix}]) +AC_MSG_NOTICE([notice ac_pwd: ${ac_pwd}]) +AC_MSG_NOTICE([notice wampcc_src_dir: ${wampcc_src_dir}]) ## ## jalson - can either be included with the source code, or pulled in externally @@ -95,7 +101,7 @@ AC_MSG_NOTICE([notice prefix: ${prefix}]) AC_MSG_NOTICE([Using bundled jalson]) internal_jalson=1 -jalsoninc="$srcdir/jalson/src" +jalsoninc="$wampcc_src_dir"/jalson/src jalsonlib="../jalson/src" AC_SUBST(jalsoninc) AC_SUBST(jalsonlib) diff --git a/examples/basic/basic_embedded_router.cc b/examples/basic/basic_embedded_router.cc index 783cf332..fdf7307e 100644 --- a/examples/basic/basic_embedded_router.cc +++ b/examples/basic/basic_embedded_router.cc @@ -29,9 +29,13 @@ int main(int argc, char** argv) auto logger = wampcc::logger::stream( std::cout, wampcc::logger::levels_upto(wampcc::logger::eInfo), false); + std::unique_ptr the_kernel( new wampcc::kernel({}, std::move(logger))); + the_kernel->get_logger().write(wampcc::logger::eInfo, wampcc::name_version(), + __FILE__, __LINE__); + /* Create an embedded wamp router. */ wampcc::wamp_router router(the_kernel.get()); diff --git a/examples/makefile b/examples/makefile index cb145b05..1ea8ea3d 100644 --- a/examples/makefile +++ b/examples/makefile @@ -5,6 +5,10 @@ # it under the terms of the MIT license. See LICENSE for details. # +# comment-out these two lines to link to shared libs +STATIC_LINK_BEGIN=-Wl,-Bstatic +STATIC_LINK_END=-Wl,-Bdynamic + ifeq ($(WAMPCC_HOME),) $(error WAMPCC_HOME undefined - set WAMPCC_HOME to where wampcc was make-installed) endif @@ -28,7 +32,7 @@ JANSSON_LIBS=-L$(JANSSON_HOME)/lib -ljansson CXXFLAGS += -MMD -MP CXXFLAGS += -Wall -O0 -g3 -ggdb -std=c++11 -pthread $(WAMPCC_INC) $(JALSON_INC) $(LIBUV_INC) -LDLIBS +=$(WAMPCC_LIBS) $(LIBUV_LIBS) $(JALSON_LIBS) $(JANSSON_LIBS) -lcrypto -lpthread +LDLIBS += $(STATIC_LINK_BEGIN) $(WAMPCC_LIBS) $(LIBUV_LIBS) $(JANSSON_LIBS) $(STATIC_LINK_END) -lcrypto -lpthread -lssl -lrt # default: callee diff --git a/lib/Makefile.am b/lib/Makefile.am index 2071c9d8..491a4ffc 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -55,4 +55,4 @@ libwampcc_la_LIBADD = -lpthread -lssl -lcrypto $(libuvlib) # - REVISION: revision of current version. Incr. base on internal changes. # - AGE: indicates compatibilty with previous version of the shlib. # -libwampcc_la_LDFLAGS = -version-info 3:0:0 +libwampcc_la_LDFLAGS = -version-info 3:1:0 diff --git a/lib/wampcc/kernel.h b/lib/wampcc/kernel.h index c502dc9b..6aed237c 100644 --- a/lib/wampcc/kernel.h +++ b/lib/wampcc/kernel.h @@ -15,7 +15,7 @@ /* Compile-time name & version */ #define WAMPCC_MAJOR_VERSION 1 -#define WAMPCC_MINOR_VERSION 1 +#define WAMPCC_MINOR_VERSION 3 #define WAMPCC_MICRO_VERSION 1 namespace wampcc diff --git a/lib/wampcc/platform.h b/lib/wampcc/platform.h index fc3ad03a..24d08689 100644 --- a/lib/wampcc/platform.h +++ b/lib/wampcc/platform.h @@ -14,6 +14,13 @@ #include #endif +#ifdef _WIN32 + #define snprintf _snprintf + #define vsnprintf _vsnprintf + #define strcasecmp _stricmp + #define strncasecmp _strnicmp +#endif + namespace wampcc { diff --git a/lib/wampcc/protocol.h b/lib/wampcc/protocol.h index 85d90fcb..47dfc69a 100644 --- a/lib/wampcc/protocol.h +++ b/lib/wampcc/protocol.h @@ -173,7 +173,7 @@ class selector_protocol : public protocol const char* name() const override { return NAME; } - void send_msg(const json_array& j) override + void send_msg(const json_array&) override { throw std::runtime_error("selector_protocol cannot send"); } diff --git a/lib/websocket_protocol.cc b/lib/websocket_protocol.cc index 3db3fbb1..1367a872 100644 --- a/lib/websocket_protocol.cc +++ b/lib/websocket_protocol.cc @@ -7,6 +7,7 @@ #include "wampcc/websocket_protocol.h" +#include "wampcc/platform.h" #include "wampcc/utils.h" #include "wampcc/tcp_socket.h" #include "wampcc/http_parser.h" @@ -65,14 +66,17 @@ inline std::string make_accept_key(const std::string& challenge) } -static bool string_list_contains(const std::string & source, - const std::string & match) +/* Test whether a HTTP header contains a desired value. Note that when checking + * request and response headers, we are generally case + * insensitive. I.e. according to RFC2616, all header field names in both HTTP + * requests and HTTP responses are case-insensitive. */ +static bool header_contains(const std::string & source, + const std::string & match) { - for (auto & i : tokenize(source.c_str(), ',', true)) { std::string trimmed = trim(i); - if (trimmed == match) + if (strcasecmp(trimmed.c_str(), match.c_str())==0) return true; } return false; @@ -226,9 +230,9 @@ void websocket_protocol::io_on_read(char* src, size_t len) { if ( m_http_parser->is_upgrade() && m_http_parser->has("Upgrade") && - string_list_contains(m_http_parser->get("Upgrade"), "websocket") && + header_contains(m_http_parser->get("Upgrade"), "websocket") && m_http_parser->has("Connection") && - string_list_contains(m_http_parser->get("Connection"), "Upgrade") && + header_contains(m_http_parser->get("Connection"), "Upgrade") && m_http_parser->has("Sec-WebSocket-Key") && m_http_parser->has("Sec-WebSocket-Version") ) { @@ -353,9 +357,9 @@ void websocket_protocol::io_on_read(char* src, size_t len) { if ( m_http_parser->is_upgrade() && m_http_parser->has("Upgrade") && - string_list_contains(m_http_parser->get("Upgrade"), "websocket") && + header_contains(m_http_parser->get("Upgrade"), "websocket") && m_http_parser->has("Connection") && - string_list_contains(m_http_parser->get("Connection"), "Upgrade") && + header_contains(m_http_parser->get("Connection"), "Upgrade") && m_http_parser->has("Sec-WebSocket-Accept") && m_http_parser->http_status_phrase() == "Switching Protocols" && m_http_parser->http_status_code() == http_parser::status_code_switching_protocols)