diff --git a/.gitignore b/.gitignore index bc2d7218..84d7079a 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,40 @@ test/Test test/core test/err test/test.txt +Makefile +compile +config.h +config.log +config.status +debian/changelog +debian/control +debian/copyright +debian/libhttpserver-dev.install +debian/libhttpserver.install +debian/rules +libhttpserver.pc +libtool +redhat/libhttpserver.SPEC +src/.deps/ +src/.libs/ +src/Makefile +src/http_endpoint.lo +src/http_endpoint.o +src/http_request.lo +src/http_request.o +src/http_resource.lo +src/http_resource.o +src/http_response.lo +src/http_response.o +src/http_utils.lo +src/http_utils.o +src/libhttpserver.la +src/string_utilities.lo +src/string_utilities.o +src/webserver.lo +src/webserver.o +stamp-h1 +test-driver +test/.deps/ +test/Makefile + diff --git a/configure.ac b/configure.ac index d4f2ae9c..dbd4b287 100644 --- a/configure.ac +++ b/configure.ac @@ -39,10 +39,6 @@ CXXFLAGS=$OLD_CXXFLAGS AC_LANG([C++]) AC_SYS_LARGEFILE -if test "`cd $srcdir; /bin/pwd`" = "`/bin/pwd`"; then - AC_MSG_ERROR("you must configure in a separate build directory") -fi - # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADER([string],[],[AC_MSG_ERROR("C++ strings not found")]) diff --git a/src/http_resource.cpp b/src/http_resource.cpp index 19a59a0f..03437315 100644 --- a/src/http_resource.cpp +++ b/src/http_resource.cpp @@ -17,10 +17,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +#include + #include "http_resource.hpp" #include "http_utils.hpp" #include "http_request.hpp" #include "http_response.hpp" +#include "details/event_tuple.hpp" #include "webserver.hpp" #include "string_utilities.hpp" diff --git a/src/http_response.cpp b/src/http_response.cpp index 11e5e2ae..c8179253 100644 --- a/src/http_response.cpp +++ b/src/http_response.cpp @@ -25,9 +25,12 @@ #include #include #include "http_utils.hpp" +#include "details/http_resource_mirror.hpp" +#include "details/event_tuple.hpp" #include "webserver.hpp" #include "http_response.hpp" + using namespace std; namespace httpserver @@ -39,7 +42,7 @@ http_response::~http_response() webserver::unlock_cache_entry(ce); } -size_t http_response::get_headers(std::map& result) +size_t http_response::get_headers(std::map& result) const { result = this->headers; return result.size(); diff --git a/src/httpserver/details/http_endpoint.hpp b/src/httpserver/details/http_endpoint.hpp index 120c6749..4094b2ba 100644 --- a/src/httpserver/details/http_endpoint.hpp +++ b/src/httpserver/details/http_endpoint.hpp @@ -38,7 +38,7 @@ class webserver; namespace details { -struct http_resource_mirror; +class http_resource_mirror; /** * Exception class throwed when a bad formatted http url is used @@ -60,7 +60,7 @@ class bad_http_endpoint : public std::exception **/ class http_endpoint { - private: + public: /** * Copy constructor. It is useful expecially to copy regex_t structure that contains dinamically allocated data. * @param h The http_endpoint to copy @@ -75,6 +75,7 @@ class http_endpoint * @param b The http_endpoint to compare to * @return boolean indicating if this is less than b. **/ + private: bool operator <(const http_endpoint& b) const; /** * Operator overload for "assignment operator". It is used to copy endpoints to existing objects. diff --git a/src/httpserver/http_request.hpp b/src/httpserver/http_request.hpp index 8b39118c..d702f35f 100644 --- a/src/httpserver/http_request.hpp +++ b/src/httpserver/http_request.hpp @@ -509,7 +509,7 @@ class http_request * Method used to set the requestor port * @param requestor The requestor port to set **/ - void set_requestor_port(short requestor) + void set_requestor_port(short requestor_port) { this->requestor_port = requestor_port; } diff --git a/src/httpserver/http_response.hpp b/src/httpserver/http_response.hpp index 05790b39..2f4114e1 100644 --- a/src/httpserver/http_response.hpp +++ b/src/httpserver/http_response.hpp @@ -322,9 +322,7 @@ class http_response * Method used to get all headers passed with the request. * @return a map containing all headers. **/ - size_t get_headers( - std::map& result - ); + size_t get_headers(std::map& result) const; /** * Method used to get all footers passed with the request. * @return a map containing all footers. diff --git a/src/httpserver/webserver.hpp b/src/httpserver/webserver.hpp index 22471e91..6b7ed075 100644 --- a/src/httpserver/webserver.hpp +++ b/src/httpserver/webserver.hpp @@ -60,11 +60,11 @@ struct httpserver_ska; }; namespace details { + class http_endpoint; class http_resource_mirror; class event_tuple; - class http_endpoint; - class daemon_item; - class modded_request; + struct daemon_item; + struct modded_request; struct cache_entry; } diff --git a/src/webserver.cpp b/src/webserver.cpp index 2e5f7fcc..8f8edd6c 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -376,7 +376,7 @@ int create_socket (int domain, int type, int protocol) /* use SOCK_STREAM rather than ai_socktype: some getaddrinfo * implementations do not set ai_socktype, e.g. RHL6.2. */ fd = socket(domain, ctype, protocol); - if ( (-1 == fd) && (EINVAL == errno) && (0 != sock_cloexec) ) + if ( (fd == -1) && (errno == EINVAL || errno == EPROTONOSUPPORT) && (sock_cloexec != 0) ) { sock_cloexec = 0; fd = socket(domain, type, protocol); @@ -512,6 +512,12 @@ bool webserver::start(bool blocking) else bind_socket = create_socket (PF_INET, SOCK_STREAM, 0); + if(bind_socket == -1) + { + perror("Unable to create socket"); + abort(); + } + setsockopt (bind_socket, SOL_SOCKET, SO_REUSEADDR, @@ -528,7 +534,11 @@ bool webserver::start(bool blocking) #endif #endif } - bind(bind_socket, servaddr, addrlen); + if(bind(bind_socket, servaddr, addrlen) == -1) + { + perror("Unable to bind specified server address"); + abort(); + } } int flags = fcntl (bind_socket, F_GETFL); flags |= O_NONBLOCK;