Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ compiler:
# Change this to your needs
before_install:
- sudo apt-get install texinfo
- wget http://199.231.187.83/resources/libmicrohttpd-0.9.26.tar.gz
- tar -xvzf libmicrohttpd-0.9.26.tar.gz
- cd libmicrohttpd-0.9.26
- wget ftp://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.37.tar.gz
- tar -xvzf libmicrohttpd-0.9.37.tar.gz
- cd libmicrohttpd-0.9.37
- ./configure --prefix=/usr
- make
- sudo make install
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ Requirements
* libmicrohttpd >= 0.9.7
* doxygen (if you want to build code reference)

Additionally, for MinGW on windows you will need:
* libwinpthread (For MinGW-w64, if you use thread model posix then you have this)
* libgnurx >= 2.5.1

Compilation
===========
libhttpserver uses the standard system where the usual build process
Expand Down
21 changes: 18 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ m4_define([libhttpserver_REVISION],[2])dnl
m4_define([libhttpserver_PKG_VERSION],[libhttpserver_MAJOR_VERSION.libhttpserver_MINOR_VERSION.libhttpserver_REVISION])dnl
m4_define([libhttpserver_LDF_VERSION],[libhttpserver_MAJOR_VERSION:libhttpserver_MINOR_VERSION:libhttpserver_REVISION])dnl
AC_INIT([libhttpserver], libhttpserver_PKG_VERSION, [electrictwister2000@gmail.com])
AM_INIT_AUTOMAKE
AM_INIT_AUTOMAKE([subdir-objects])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])

Expand All @@ -53,6 +53,21 @@ if test x"$samedirectory" = x"no"; then
fi
fi

case "$host" in
*-mingw*)
NETWORK_HEADER="winsock2.h"
REGEX_LIBS="-lregex -no-undefined"
;;
*-cygwin*)
NETWORK_HEADER="winsock2.h"
REGEX_LIBS="-lregex -no-undefined"
;;
*)
NETWORK_HEADER="arpa/inet.h"
REGEX_LIBS=""
;;
esac

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADER([string],[],[AC_MSG_ERROR("C++ strings not found")])
Expand All @@ -73,7 +88,7 @@ AC_CHECK_HEADER([ctype.h],[],[AC_MSG_ERROR("cctype not found")])
AC_CHECK_HEADER([regex.h],[],[AC_MSG_ERROR("regex.h not found")])
AC_CHECK_HEADER([sys/stat.h],[],[AC_MSG_ERROR("sys/stat.h not found")])
AC_CHECK_HEADER([sys/types.h],[],[AC_MSG_ERROR("sys/types.h not found")])
AC_CHECK_HEADER([arpa/inet.h],[],[AC_MSG_ERROR("arpa/inet.h not found")])
AC_CHECK_HEADER([$NETWORK_HEADER],[],[AC_MSG_ERROR("$NETWORK_HEADER not found")])
AC_CHECK_HEADER([signal.h],[],[AC_MSG_ERROR("signal.h not found")])

AC_CHECK_HEADER([gnutls/gnutls.h],[have_gnutls="yes"],[AC_MSG_WARN("gnutls/gnutls.h not found. TLS will be disabled"); have_gnutls="no"])
Expand All @@ -84,7 +99,7 @@ PKG_CHECK_MODULES([LIBMICROHTTPD],[libmicrohttpd >= 0.9.7],[],[AC_MSG_ERROR("lib
#AC_CHECK_LIB([microhttpd],[MHD_start_daemon],[],[AC_MSG_ERROR("Microhttpd header files not found. Please use a version >= 0.9.9.")])

CXXFLAGS="-DHTTPSERVER_COMPILATION -D_REENTRANT $LIBMICROHTTPD_CFLAGS $CXXFLAGS"
LDFLAGS="$LIBMICROHTTPD_LIBS $LD_FLAGS"
LDFLAGS="$LIBMICROHTTPD_LIBS $REGEX_LIBS $LD_FLAGS"

m4_pattern_allow([AC_TYPE_SIZE_T])
m4_pattern_allow([AC_TYPE_UINT16_T])
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ AM_CXXFLAGS += -fPIC -Wall
libhttpserver_la_LIBADD = -lmicrohttpd
libhttpserver_la_LDFLAGS =

install-exec-hook:
install-data-hook:
(mkdir -p $(DESTDIR)$(includedir) && cd $(DESTDIR)$(includedir) && $(LN_S) -f httpserver.hpp httpserverpp)

uninstall-hook:
Expand Down
3 changes: 2 additions & 1 deletion src/details/comet_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <errno.h>
#include <iostream>
#include "details/comet_manager.hpp"
#include <sys/time.h>

using namespace std;

Expand Down Expand Up @@ -140,7 +141,7 @@ size_t comet_manager::get_topic_consumers(
{
consumers.insert((*it));
}
int size = consumers.size();
std::set<httpserver::http::httpserver_ska>::size_type size = consumers.size();
pthread_rwlock_unlock(&comet_guard);
return size;
}
Expand Down
6 changes: 3 additions & 3 deletions src/details/http_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ http_endpoint::http_endpoint
(parts[i][parts[i].size() - 1] == '}')
)
{
int bar = parts[i].find_first_of('|');
if(bar != (int)string::npos)
std::string::size_type bar = parts[i].find_first_of('|');
if(bar != string::npos)
{
this->url_pars.push_back(parts[i].substr(1, bar - 1));
if(first)
Expand Down Expand Up @@ -201,7 +201,7 @@ http_endpoint& http_endpoint::operator =(const http_endpoint& h)

bool http_endpoint::operator <(const http_endpoint& b) const
{
COMPARATOR(this->url_modded, b.url_modded, toupper);
COMPARATOR(this->url_modded, b.url_modded, std::toupper);
}

bool http_endpoint::match(const http_endpoint& url) const
Expand Down
4 changes: 2 additions & 2 deletions src/http_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ namespace details

ssize_t cb(void* cls, uint64_t pos, char* buf, size_t max)
{
int val = static_cast<http_response*>(cls)->cycle_callback(buf);
ssize_t val = static_cast<http_response*>(cls)->cycle_callback(buf);
if(val == -1)
static_cast<http_response*>(cls)->completed = true;
return val;
Expand Down Expand Up @@ -272,7 +272,7 @@ ssize_t http_response::data_generator(
if(_this->ws->pop_signaled(_this->connection_id))
{
string message;
int size = _this->ws->read_message(_this->connection_id, message);
size_t size = _this->ws->read_message(_this->connection_id, message);
memcpy(buf, message.c_str(), size);
return size;
}
Expand Down
8 changes: 8 additions & 0 deletions src/http_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(__MINGW32__) || defined(__CYGWIN32__)
#define _WINDOWS
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x600
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <arpa/inet.h>
#endif
#include <sstream>
#include <iomanip>
#include <fstream>
Expand Down
6 changes: 3 additions & 3 deletions src/httpserver/create_webserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class create_webserver
{
}

explicit create_webserver(int port):
explicit create_webserver(uint16_t port):
_port(port),
_start_method(http::http_utils::INTERNAL_SELECT),
_max_threads(0),
Expand Down Expand Up @@ -125,7 +125,7 @@ class create_webserver
{
}

create_webserver& port(int port) { _port = port; return *this; }
create_webserver& port(uint16_t port) { _port = port; return *this; }
create_webserver& start_method(
const http::http_utils::start_method_T& start_method
)
Expand Down Expand Up @@ -317,7 +317,7 @@ class create_webserver
}

private:
int _port;
uint16_t _port;
http::http_utils::start_method_T _start_method;
int _max_threads;
int _max_connections;
Expand Down
2 changes: 1 addition & 1 deletion src/httpserver/details/event_tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace details
fd_set*,
fd_set*,
fd_set*,
int*
MHD_socket*
);

typedef struct timeval(*get_timeout_ptr)();
Expand Down
2 changes: 1 addition & 1 deletion src/httpserver/event_supplier.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class event_supplier
fd_set* read_fdset,
fd_set* write_fdset,
fd_set* exc_fdset,
int* max
MHD_socket* max
) const
{
static_cast<CHILD*>(this)->supply_events(
Expand Down
10 changes: 5 additions & 5 deletions src/httpserver/http_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include <microhttpd.h>
#include <string>
#include <ctype.h>
#include <cctype>
#include <vector>
#include <algorithm>
#include <exception>
Expand Down Expand Up @@ -238,8 +238,8 @@ class http_utils
\
for (size_t n = 0; n < l1; n++)\
{\
char xc = op((x)[n]);\
char yc = op((y)[n]);\
int xc = op((x)[n]);\
int yc = op((y)[n]);\
if (xc < yc) return true;\
if (xc > yc) return false;\
}\
Expand All @@ -255,7 +255,7 @@ class header_comparator {
**/
bool operator()(const std::string& x,const std::string& y) const
{
COMPARATOR(x, y, toupper);
COMPARATOR(x, y, std::toupper);
}
};

Expand All @@ -274,7 +274,7 @@ class arg_comparator {
bool operator()(const std::string& x,const std::string& y) const
{
#ifdef CASE_INSENSITIVE
COMPARATOR(x, y, toupper);
COMPARATOR(x, y, std::toupper);
#else
COMPARATOR(x, y, );
#endif
Expand Down
6 changes: 4 additions & 2 deletions src/httpserver/webserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class webserver
webserver& operator=(const webserver& other);

private:
const int port;
const uint16_t port;
http::http_utils::start_method_T start_method;
const int max_threads;
const int max_connections;
Expand All @@ -200,7 +200,9 @@ class webserver
validator_ptr validator;
unescaper_ptr unescaper;
const struct sockaddr* bind_address;
int bind_socket;
/* Changed type to MHD_socket because this type will always reflect the
platform's actual socket type (e.g. SOCKET on windows, int on unixes)*/
MHD_socket bind_socket;
const int max_thread_stack_size;
const bool use_ssl;
const bool use_ipv6;
Expand Down
Loading