Skip to content

Commit

Permalink
New MIT license, remove makefile, add cmake support, files tree refac…
Browse files Browse the repository at this point in the history
…toring
  • Loading branch information
antonino.calderone committed Jul 12, 2019
1 parent cdf93d1 commit bd8b86c
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 713 deletions.
1 change: 0 additions & 1 deletion AUTHORS

This file was deleted.

11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8.12)

include_directories(. include)

file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/cppsrc/*.cc")

set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14" )

add_executable(thttpd ${SOURCES})

target_link_libraries(thttpd -pthread)
359 changes: 19 additions & 340 deletions COPYING

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions NEWS

This file was deleted.

29 changes: 15 additions & 14 deletions README
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
This file is part of thttpd
Copyright (c) Antonino Calderone ([email protected])
All rights reserved.
Licensed under the MIT License.
See COPYING file in the project root for full license information.
-------------------------------------------------------------------------------

TinyHttpServer is a lightweight web server implemented in C++11
Expand Down Expand Up @@ -37,7 +31,14 @@ tiny_http_server.vcxproj
information about the platforms, configurations, and project features selected with the
Application Wizard.

makefile
This is a makefile
CMakeLists.txt
This is a cmakefile


-------------------------------------------------------------------------------
* Building TinyHttpServer using cmake

Create build directory and run cmake:
mkdir build && cd build && cmake ..


Author A. Calderone - [email protected]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# thttpd
TinyHttpServer is a lightweight web server implemented in C++11

![TinyHttpServer](tinyhttp.png)
![TinyHttpServer](pics/tinyhttp.png)

TinyHttpServer is a portable tiny HTTP server implementation written in C++11 (you may compile it using either MS Visual Studio or GNU GCC).

Expand Down Expand Up @@ -60,11 +60,11 @@ This classification is called Multimedia Internet Mail Extensions (MIME) because
The MIME classification is made by a type, a subtype and optionally a parameter. For example, plain text is normally classified by specifying the attribute
"Content-Type: text/plain; charset=us-ascii"

![HTTP Server](tinyhttp1.png)
![HTTP Server](pics/tinyhttp1.png)

## Thread model
![HTTP Server](tinyhttp2.png)
![HTTP Server](pics/tinyhttp2.png)

## Pseudo code
![HTTP Server](tinyhttp3.png)
![HTTP Server](pics/tinyhttp3.png)

2 changes: 0 additions & 2 deletions THANKS

This file was deleted.

32 changes: 10 additions & 22 deletions gen_utils.cc → cppsrc/gen_utils.cc
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
/*
* gen_utils.cc
*
* This file is part of TinyHttpServer
*
* TinyHttpServer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* TinyHttpServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TinyHttpServer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
*
* Author: Antonino Calderone, <[email protected]>
*
*/
//
// This file is part of thttpd
// Copyright (c) Antonino Calderone ([email protected])
// All rights reserved.
// Licensed under the MIT License.
// See COPYING file in the project root for full license information.
//


/* -------------------------------------------------------------------------- */

/// \file gen_utils.cc
/// \brief Collection of general purpose utilities
Expand Down
41 changes: 14 additions & 27 deletions http_mime.cc → cppsrc/http_mime.cc
Original file line number Diff line number Diff line change
@@ -1,42 +1,28 @@
/*
* http_mime.cc
*
* This file is part of TinyHttpServer
*
* TinyHttpServer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* TinyHttpServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TinyHttpServer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
*
* Author: Antonino Calderone, <[email protected]>
*
*/
//
// This file is part of thttpd
// Copyright (c) Antonino Calderone ([email protected])
// All rights reserved.
// Licensed under the MIT License.
// See COPYING file in the project root for full license information.
//


// ----------------------------------------------------------------------------

/* -------------------------------------------------------------------------- */

/// \file http_mime.cc
/// \brief Definition of MIME table


// ----------------------------------------------------------------------------

/* -------------------------------------------------------------------------- */

#include "http_server.h"

#include <map>
#include <string>


/* -------------------------------------------------------------------------- */

std::map<std::string, std::string> http_response_t::_mime_tbl = {
{ ".3dm", "x-world/x-3dmf" }, { ".3dmf", "x-world/x-3dmf" },
{ ".a", "application/octet-stream" },
Expand Down Expand Up @@ -304,4 +290,5 @@ std::map<std::string, std::string> http_response_t::_mime_tbl = {
};


// ----------------------------------------------------------------------------
/* -------------------------------------------------------------------------- */

36 changes: 12 additions & 24 deletions http_server.cc → cppsrc/http_server.cc
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
/*
* http_server.cc
*
* This file is part of TinyHttpServer
*
* TinyHttpServer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* TinyHttpServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TinyHttpServer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
*
* Author: Antonino Calderone, <[email protected]>
*
*/
//
// This file is part of thttpd
// Copyright (c) Antonino Calderone ([email protected])
// All rights reserved.
// Licensed under the MIT License.
// See COPYING file in the project root for full license information.
//


/* -------------------------------------------------------------------------- */

/// \file http_server.cc
/// \brief Implementation of HTTP classes


/* -------------------------------------------------------------------------- */
// HTTP Server

Expand Down Expand Up @@ -212,8 +200,8 @@ http_request_t::handle_t http_socket_t::recv()
case crlf_t::CR2:
s = (c == '\n') ? crlf_t::LF2 : crlf_t::IDLE;
break;
default:
break;
default:
break;
}

return s == crlf_t::LF2;
Expand Down
29 changes: 7 additions & 22 deletions os_dep.cc → cppsrc/os_dep.cc
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
/*
* os_dep.cc
*
* This file is part of TinyHttpServer
*
* TinyHttpServer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* TinyHttpServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TinyHttpServer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
*
* Author: Antonino Calderone, <[email protected]>
*
*/
//
// This file is part of thttpd
// Copyright (c) Antonino Calderone ([email protected])
// All rights reserved.
// Licensed under the MIT License.
// See COPYING file in the project root for full license information.
//


/* -------------------------------------------------------------------------- */
Expand Down
31 changes: 9 additions & 22 deletions socket_utils.cc → cppsrc/socket_utils.cc
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
/*
* socket_utils.cc
*
* This file is part of TinyHttpServer
*
* TinyHttpServer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* TinyHttpServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TinyHttpServer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
*
* Author: Antonino Calderone, <[email protected]>
*
*/
//
// This file is part of thttpd
// Copyright (c) Antonino Calderone ([email protected])
// All rights reserved.
// Licensed under the MIT License.
// See COPYING file in the project root for full license information.
//


/* -------------------------------------------------------------------------- */

/// \file socket_utils.cc
/// \brief Implementation of socket classes containing some
/// useful stuff cross-platform for manipulating socket
Expand Down
File renamed without changes.
31 changes: 9 additions & 22 deletions tiny_http_server.cc → cppsrc/tiny_http_server.cc
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
/*
* tiny_http_server.cc
*
* This file is part of TinyHttpServer
*
* TinyHttpServer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* TinyHttpServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TinyHttpServer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
*
* Author: Antonino Calderone, <[email protected]>
*
*/
//
// This file is part of thttpd
// Copyright (c) Antonino Calderone ([email protected])
// All rights reserved.
// Licensed under the MIT License.
// See COPYING file in the project root for full license information.
//


/* -------------------------------------------------------------------------- */
Expand All @@ -39,7 +24,9 @@ class prog_args_t {
std::string _prog_name;
std::string _command_line;
std::string _web_root = HTTP_SERVER_WROOT;

tcp_socket_t::port_t _http_server_port = HTTP_SERVER_PORT;

bool _show_help = false;
bool _show_ver = false;
bool _error = false;
Expand Down
Loading

0 comments on commit bd8b86c

Please sign in to comment.