Skip to content
Closed
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
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 0 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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")])
Expand Down
4 changes: 4 additions & 0 deletions src/http_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

*/

#include <stdlib.h>

#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"

Expand Down
5 changes: 4 additions & 1 deletion src/http_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
#include <fcntl.h>
#include <unistd.h>
#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
Expand All @@ -39,7 +42,7 @@ http_response::~http_response()
webserver::unlock_cache_entry(ce);
}

size_t http_response::get_headers(std::map<std::string, std::string, header_comparator>& result)
size_t http_response::get_headers(std::map<std::string, std::string, header_comparator>& result) const
{
result = this->headers;
return result.size();
Expand Down
5 changes: 3 additions & 2 deletions src/httpserver/details/http_endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/httpserver/http_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/httpserver/http_response.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,7 @@ class http_response
* Method used to get all headers passed with the request.
* @return a map<string,string> containing all headers.
**/
size_t get_headers(
std::map<std::string, std::string, header_comparator>& result
);
size_t get_headers(std::map<std::string, std::string, header_comparator>& result) const;
/**
* Method used to get all footers passed with the request.
* @return a map<string,string> containing all footers.
Expand Down
6 changes: 3 additions & 3 deletions src/httpserver/webserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 12 additions & 2 deletions src/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down