From f3d06b2857158c11e4e7b2a283db98f5580e65ee Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Thu, 6 Oct 2016 15:01:41 +0800 Subject: [PATCH] Use custom Server header in http response --- .travis.yml | 6 +++--- src/server.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 189ef6d..afcd0a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,11 +18,11 @@ addons: - libssl-dev install: - echo $TRAVIS_OS_NAME - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; brew unlink cmake json-c; brew install cmake openssl json-c; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install cmake openssl json-c; export CMAKE_OPTIONS="-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"; fi - echo "Compiling libwebsockets-$LIBWEBSOCKETS_VERSION from source..." - - pushd /tmp; curl -sLo- https://github.com/warmcat/libwebsockets/archive/$LIBWEBSOCKETS_VERSION.tar.gz | tar xz; cd libwebsockets-*; cmake .; make && sudo make install; popd + - pushd /tmp; curl -sLo- https://github.com/warmcat/libwebsockets/archive/$LIBWEBSOCKETS_VERSION.tar.gz | tar xz; cd libwebsockets-*; cmake $CMAKE_OPTIONS .; make && sudo make install; popd script: - echo $TRAVIS_OS_NAME - cmake --version - mkdir build && cd build - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .. && make; else cmake .. && make; fi + - cmake $CMAKE_OPTIONS .. && make diff --git a/src/server.c b/src/server.c index faffd68..7792cfa 100644 --- a/src/server.c +++ b/src/server.c @@ -272,6 +272,12 @@ main(int argc, char **argv) { lws_set_log_level(debug_level, NULL); +#if LWS_LIBRARY_VERSION_MAJOR == 2 + char server_hdr[128] = ""; + sprintf(server_hdr, "ttyd/%s (libwebsockets/%s)", TTYD_VERSION, LWS_LIBRARY_VERSION); + info.server_string = server_hdr; +#endif + if (strlen(iface) > 0) info.iface = iface; if (ssl) { -- 2.43.4