diff --git a/CREDITS.md b/CREDITS.md index 1e4f3c14..e0a68a4b 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -1,4 +1,9 @@ +# Libhttp Contributors + +* Lammert Bies + # Civetweb Contributors +Libhttp is based on Civetweb which is based on the MIT licensed version of Mongoose. The contributors list mentioned here is the list as it was present in the CREDITS.md file of the Civetweb project when it was forked to Libhttp. * Alex Kozlov * bel2125 diff --git a/LICENSE.md b/LICENSE.md index 263690e5..4ec8173c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -6,12 +6,14 @@ aspects of the software. Not all licenses may apply depending on the features chosen. -Civetweb License +Libhttp License ----- ### Included with all features. -> Copyright (c) 2013-2015 The CivetWeb developers ([CREDITS.md](https://github.com/civetweb/civetweb/blob/master/CREDITS.md)) +> Copyright (c) 2016 Lammert Bies +> +> Copyright (c) 2013-2016 The CivetWeb developers ([CREDITS.md](https://github.com/civetweb/civetweb/blob/master/CREDITS.md)) > > Copyright (c) 2004-2013 Sergey Lyubka > diff --git a/README.md b/README.md index 8c3e7ab7..ae55fab5 100644 --- a/README.md +++ b/README.md @@ -12,41 +12,37 @@ Libhttp can be used by developers as a library, to add web server functionality It can also be used by end users as a stand-alone web server. It is available as single executable, no installation is required. Libhttp is a fork of the Mongoose (MIT)/Civetweb family of http server libraries with the focus on event -driven efficient communication and good documentation. +driven efficient communication, clean code and good documentation. Where to find the official version? ----------------------------------- -End users can download Libhttp at Github - +Documentation of the library can be found on [www.libhttp.org](http://www.libhttp.org) -Developers can contribute to Libhttp via GitHub +Developers can download and contribute to Libhttp via GitHub [https://github.com/lammertb/libhttp](https://github.com/lammertb/libhttp) Trouble tickets should be filed on GitHub [https://github.com/lammertb/libhttp/issues](https://github.com/lammertb/libhttp/issues) - - - Quick start documentation -------------------------- -- [docs/Installing.md](https://github.com/civetweb/civetweb/blob/master/docs/Installing.md) - Install Guide (for end users using pre-built binaries) -- [docs/UserManual.md](https://github.com/civetweb/civetweb/blob/master/docs/UserManual.md) - End User Guide -- [docs/Building.md](https://github.com/civetweb/civetweb/blob/master/docs/Building.md) - Building the Server (quick start guide) -- [docs/Embedding.md](https://github.com/civetweb/civetweb/blob/master/docs/Embedding.md) - Embedding (how to add HTTP support to an existing application) -- [docs/OpenSSL.md](https://github.com/civetweb/civetweb/blob/master/docs/OpenSSL.md) - Adding HTTPS (SSL/TLS) support using OpenSSL. -- [RELEASE_NOTES.md](https://github.com/civetweb/civetweb/blob/master/RELEASE_NOTES.md) - Release Notes -- [LICENSE.md](https://github.com/civetweb/civetweb/blob/master/LICENSE.md) - Copyright License +- [docs/APIReference.md](docs/APIReference.md) - Reference of the C programming API +- [docs/Installing.md](docs/Installing.md) - Install Guide (for end users using pre-built binaries) +- [docs/UserManual.md](docs/UserManual.md) - End User Guide +- [docs/Building.md](docs/Building.md) - Building the Server (quick start guide) +- [docs/Embedding.md](docs/Embedding.md) - Embedding (how to add HTTP support to an existing application) +- [docs/OpenSSL.md](docs/OpenSSL.md) - Adding HTTPS (SSL/TLS) support using OpenSSL. +- [RELEASE_NOTES.md](RELEASE_NOTES.md) - Release Notes +- [LICENSE.md](LICENSE.md) - Copyright License Overview -------- -CivetWeb keeps the balance between functionality and +LibHTTP keeps the balance between functionality and simplicity by a carefully selected list of features: - Liberal, commercial-friendly, permissive, @@ -56,7 +52,7 @@ simplicity by a carefully selected list of features: - Forked from [Mongoose](https://code.google.com/p/mongoose/) in 2013, before it changed the licence from MIT to commercial + GPL. A lot of enchancements have been added since that time, see - [RELEASE_NOTES.md](https://github.com/civetweb/civetweb/blob/master/RELEASE_NOTES.md). + [RELEASE_NOTES.md](RELEASE_NOTES.md). - Works on Windows, Mac, Linux, UNIX, iPhone, Android, Buildroot, and many other platforms. - Scripting and database support (Lua scipts, Lua Server Pages, CGI + SQLite @@ -78,31 +74,30 @@ simplicity by a carefully selected list of features: ### Optionally included software -![Lua](https://raw.github.com/civetweb/civetweb/master/resources/lua-logo.jpg "Lua Logo") +![Lua](https://raw.github.com/lammertb/libhttp/master/resources/lua-logo.jpg "Lua Logo") -![Sqlite3](https://raw.github.com/civetweb/civetweb/master/resources/sqlite3-logo.jpg "Sqlite3 Logo") +![Sqlite3](https://raw.github.com/lammertb/libhttp/master/resources/sqlite3-logo.jpg "Sqlite3 Logo") -![LuaFileSystem](https://raw.github.com/civetweb/civetweb/master/resources/luafilesystem-logo.jpg "LuaFileSystem Logo") +![LuaFileSystem](https://raw.github.com/lammertb/libhttp/master/resources/luafilesystem-logo.jpg "LuaFileSystem Logo") -![LuaSQLite3](https://raw.github.com/civetweb/civetweb/master/resources/luasqlite-logo.jpg "LuaSQLite3 Logo") +![LuaSQLite3](https://raw.github.com/lammertb/libhttp/master/resources/luasqlite-logo.jpg "LuaSQLite3 Logo") -![LuaXML](https://raw.github.com/civetweb/civetweb/master/resources/luaxml-logo.jpg "LuaXML Logo") +![LuaXML](https://raw.github.com/lammertb/libhttp/master/resources/luaxml-logo.jpg "LuaXML Logo") -![Duktape](https://raw.github.com/civetweb/civetweb/master/resources/duktape-logo.png "Duktape Logo") +![Duktape](https://raw.github.com/lammertb/libhttp/master/resources/duktape-logo.png "Duktape Logo") Support ------- -This project is very easy to install and use. Please read the [documentation](https://github.com/civetweb/civetweb/blob/master/docs/) -and have a look at the [examples] (https://github.com/civetweb/civetweb/blob/master/examples/). -More information may be found on the [mailing list](https://groups.google.com/d/forum/civetweb). +This project is very easy to install and use. Please read the [documentation](docs/) +and have a look at the [examples] (examples/). Contributions @@ -113,24 +108,27 @@ Contributions are welcome provided all contributions carry the MIT license. DO NOT APPLY fixes copied from Mongoose to this project to prevent GPL tainting. Since 2013 CivetWeb and Mongoose are developed independently. By now the code base differs, so patches cannot be safely transfered in either direction. -Some guidelines can be found in [docs/Contribution.md](https://github.com/civetweb/civetweb/blob/master/docs/Contribution.md). +Some guidelines can be found in [docs/Contribution.md](docs/Contribution.md). ### Authors -CivetWeb is based on the Mongoose project. The original author of Mongoose was +LibHTTP is based on CivetWeb which in turn is based on the Mongoose project. The original author of Mongoose was Sergey Lyubka (Copyright (c) 2004-2013 Sergey Lyubka, MIT license). However, in August 16, 2013, the [license of Mongoose has been changed](https://groups.google.com/forum/#!topic/mongoose-users/aafbOnHonkI) after writing and distributing the original code this project is based on. -The license change used to be described on the Mongoose Wikipedia page as well, but it's getting deleted there regularly. CivetWeb has been forked from the last MIT version of Mongoose. Since 2013, CivetWeb has seen many improvements from various authors (Copyright (c) 2013-2016 the CivetWeb developers, MIT license). -A list of authors can be found in [CREDITS.md](https://github.com/civetweb/civetweb/blob/master/CREDITS.md). +A list of authors can be found in [CREDITS.md](CREDITS.md). -Using the CivetWeb project ensures the MIT licenses terms are applied and +LibHTTP has been forked from a 2016 version of CivetWeb. It contains all updates in CivetWeb +upto the moment of forking and updates of later dates in CivetWeb may be used in LibHTTP +because they both use the same license. It is expected though that both projects will +go in different directions though so future compatibility is not guaranteed. + +Using the LibHTTP project ensures the MIT licenses terms are applied and GPL cannot be imposed on any of this code as long as it is sourced from here. This code will remain free with the MIT license protection. - diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index af068287..ed6b8fc4 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,16 @@ -Release Notes v1.9 (work in progress) +Release Notes v2.0 (work in progress) +=== +### Objectives: *Clean up source code, proper documentation, focus on embedding* + +Changes +------- +- Changed references from CivetWeb to LibHTTP in documentation +- Removed deprecated function `mg_upload();` +- Removed deprecated function `mg_get_valid_option_names();` +- Removed all build scripts except the script for `make` + + +Release Notes v1.9 (will never be released as LibHTTP) === ### Objectives: *Read client certificate information, bug fixes* diff --git a/build.cmd b/build.cmd deleted file mode 100644 index 8ccf0e4b..00000000 --- a/build.cmd +++ /dev/null @@ -1,866 +0,0 @@ -:: Make sure the extensions are enabled -@verify other 2>nul -@setlocal EnableDelayedExpansion -@if errorlevel 1 ( - call :print_usage "Failed to enable extensions" - exit /b 1 -) - -::Change the code page to unicode -@chcp 65001 1>nul 2>nul -@if errorlevel 1 ( - call :print_usage "Failed to change the code page to unicode" - exit /b 1 -) - -:: Set up some global variables -@set project=civetweb -@set "script_name=%~nx0" -@set "script_folder=%~dp0" -@set "script_folder=%script_folder:~0,-1%" -@set "output_path=%script_folder%\output" -@set "build_path=%output_path%\build" -@set "install_path=%output_path%\install" -@set build_shared=OFF -@set build_type=Release -@set dependency_path=%TEMP%\%project%-build-dependencies - -:: Check the command line parameters -@set logging_level=1 -@set "options=%* " -@if not "!options!"=="!options:/? =!" set usage="Convenience script to build %project% with CMake" -@for %%a in (%options%) do @( - @set arg=%%~a - @set arg=!arg: =! - @set one=!arg:~0,1! - @set two=!arg:~0,2! - @if /i [!arg!] == [/q] set quiet=true - @if /i [!two!] == [/v] call :verbosity "!arg!" - @if /i [!arg!] == [/s] set build_shared=ON - @if /i [!arg!] == [/d] set build_type=Debug - @if /i not [!one!] == [/] ( - if not defined generator ( - set generator=!arg! - ) else ( - set usage="Too many generators: !method! !arg!" ^ - "There should only be one generator parameter" - ) - ) -) -@if defined quiet ( - set logging_level=0 -) -@if not defined generator ( - set generator=MSVC -) -@if /i not [%generator%] == [MinGW] ( - if /i not [%generator%] == [MSVC] ( - call :print_usage "Invalid argument: %generator%" - exit /b 1 - ) -) - -:: Set up the logging -@set log_folder=%output_path%\logs -@call :iso8601 timestamp -@set log_path=%log_folder%\%timestamp%.log -@set log_keep=10 - -:: Only keep a certain amount of logs -@set /a "log_keep=log_keep-1" -@if not exist %log_folder% @mkdir %log_folder% -@for /f "skip=%log_keep%" %%f in ('dir /b /o-D /tc %log_folder%') do @( - call :log 4 "Removing old log file %log_folder%\%%f" - del %log_folder%\%%f -) - -:: Set up some more global variables -@call :architecture arch -@call :windows_version win_ver win_ver_major win_ver_minor win_ver_rev -@call :script_source script_source -@if [%script_source%] == [explorer] ( - set /a "logging_level=logging_level+1" -) - -:: Print the usage or start the script -@set exit_code=0 -@if defined usage ( - call :print_usage %usage% -) else ( - call :main - @if errorlevel 1 ( - @call :log 0 "Failed to build the %project% project" - @set exit_code=1 - ) -) - -:: Tell the user where the built files are -@call :log 5 -@call :log 0 "The built files are available in %install_path%" - -:: Stop the script if the user double clicked -@if [%script_source%] == [explorer] ( - pause -) - -@exit /b %exit_code% -@endlocal -@goto :eof - -:: -------------------------- Functions start here ---------------------------- - -:main - Main function that performs the build -@setlocal -@call :log 6 -@call :log 2 "Welcome to the %project% build script" -@call :log 6 "------------------------------------" -@call :log 6 -@call :log 2 "This script builds the project using CMake" -@call :log 6 -@call :log 2 "Generating %generator%..." -@call :log 6 -@set methods=dependencies ^ - generate ^ - build ^ - install -@for %%m in (%methods%) do @( - call :log 3 "Excuting the '%%m' method" - call :log 8 - call :%%~m - if errorlevel 1 ( - call :log 0 "Failed to complete the '%%~m' dependency routine" - call :log 0 "View the log at %log_path%" - exit /b 1 - ) -) -@call :log 6 "------------------------------------" -@call :log 2 "Build complete" -@call :log 6 -@endlocal -@goto :eof - -:print_usage - Prints the usage of the script -:: %* - message to print, each argument on it's own line -@setlocal -@for %%a in (%*) do @echo.%%~a -@echo. -@echo.build [/?][/v[v...]^|/q][MinGW^|MSVC] -@echo. -@echo. [MinGW^|(MSVC)] -@echo. Builds the library with one of the compilers -@echo. /s Builds shared libraries -@echo. /d Builds a debug variant of the project -@echo. /v Sets the output to be more verbose -@echo. /v[v...] Extra verbosity, /vv, /vvv, etc -@echo. /q Quiets the output -@echo. /? Shows this usage message -@echo. -@endlocal -@goto :eof - -:dependencies - Installs any prerequisites for the build -@setlocal EnableDelayedExpansion -@if errorlevel 1 ( - call :log 0 "Failed to enable extensions" - exit /b 1 -) -@call :log 5 -@call :log 0 "Installing dependencies for %generator%" -@if /i [%generator%] == [MinGW] ( - call :mingw compiler_path - @if errorlevel 1 ( - @call :log 5 - @call :log 0 "Failed to find MinGW" - @exit /b 1 - ) - set "PATH=!compiler_path!;%PATH%" - @call :find_in_path gcc_executable gcc.exe - @if errorlevel 1 ( - @call :log 5 - @call :log 0 "Failed to find gcc.exe" - @exit /b 1 - ) -) -@if [%reboot_required%] equ [1] call :reboot -@endlocal & set "PATH=%PATH%" -@goto :eof - -:generate - Uses CMake to generate the build files -@setlocal EnableDelayedExpansion -@if errorlevel 1 ( - call :log 0 "Failed to enable extensions" - exit /b 1 -) -@call :log 5 -@call :log 0 "Generating CMake files for %generator%" -@call :cmake cmake_executable -@if errorlevel 1 ( - @call :log 5 - @call :log 0 "Need CMake to create the build files" - @exit /b 1 -) -@if /i [%generator%] == [MinGW] @( - @set "generator_var=-G "MinGW Makefiles^"" -) -@if /i [%generator%] == [MSVC] @( - rem We could figure out the correct MSVS generator here -) -@call :iso8601 iso8601 -@set output=%temp%\cmake-%iso8601%.log -@if not exist %build_path% mkdir %build_path% -@cd %build_path% -@"%cmake_executable%" ^ - !generator_var! ^ - -DCMAKE_BUILD_TYPE=!build_type! ^ - -DBUILD_SHARED_LIBS=!build_shared! ^ - "%script_folder%" > "%output%" -@if errorlevel 1 ( - @call :log 5 - @call :log 0 "Failed to generate build files with CMake" - @call :log_append "%output%" - @cd %script_folder% - @exit /b 1 -) -@cd %script_folder% -@endlocal -@goto :eof - -:build - Builds the library -@setlocal EnableDelayedExpansion -@if errorlevel 1 ( - call :log 0 "Failed to enable extensions" - exit /b 1 -) -@call :log 5 -@call :log 0 "Building %project% with %generator%" -@if /i [%generator%] == [MinGW] @( - @call :find_in_path mingw32_make_executable mingw32-make.exe - @if errorlevel 1 ( - @call :log 5 - @call :log 0 "Failed to find mingw32-make" - @exit /b 1 - ) - @set "build_command=^"!mingw32_make_executable!^" all test" -) -@if /i [%generator%] == [MSVC] @( - @call :msbuild msbuild_executable - @if errorlevel 1 ( - @call :log 5 - @call :log 0 "Failed to find MSBuild" - @exit /b 1 - ) - @set "build_command=^"!msbuild_executable!^" /m:4 /p:Configuration=%build_type% %project%.sln" -) -@if not defined build_command ( - @call :log 5 - @call :log 0 "No build command for %generator%" - @exit /b 1 -) -@cd %build_path% -@call :iso8601 iso8601 -@set output=%temp%\build-%iso8601%.log -@call :log 7 -@call :log 2 "Build command: %build_command:"=%" -@%build_command% > "%output%" -@if errorlevel 1 ( - @call :log_append "%output%" - @call :log 5 - @call :log 0 "Failed to complete the build" - @exit /b 1 -) -@call :log_append "%output%" -@cd %script_folder% -@endlocal -@goto :eof - -:install - Installs the built files -@setlocal -@call :log 5 -@call :log 0 "Installing built files" -@call :cmake cmake_executable -@if errorlevel 1 ( - @call :log 5 - @call :log 0 "Need CMake to install the built files" - @exit /b 1 -) -@call :iso8601 iso8601 -@set output=%temp%\install-%iso8601%.log -@"%cmake_executable%" ^ - "-DCMAKE_INSTALL_PREFIX=%install_path%" ^ - -P "%build_path%/cmake_install.cmake" ^ - > "%output%" -@if errorlevel 1 ( - @call :log_append "%output%" - @call :log 5 - @call :log 0 "Failed to install the files" - @exit /b 1 -) -@call :log_append "%output%" -@endlocal -@goto :eof - -:script_source - Determines if the script was ran from the cli or explorer -:: %1 - The return variable [cli|explorer] -@verify other 2>nul -@setlocal EnableDelayedExpansion -@if errorlevel 1 ( - call :log 0 "Failed to enable extensions" - exit /b 1 -) -@call :log 3 "Attempting to detect the script source" -@echo "The invocation command was: '%cmdcmdline%'" >> %log_path% -@for /f "tokens=1-3,*" %%a in ("%cmdcmdline%") do @( - set cmd=%%~a - set arg1=%%~b - set arg2=%%~c - set rest=%%~d -) -@set quote=" -@if "!arg2:~0,1!" equ "!quote!" ( - if "!arg2:~-1!" neq "!quote!" ( - set "arg2=!arg2:~1!" - ) -) -@call :log 4 "cmd = %cmd%" -@call :log 4 "arg1 = %arg1%" -@call :log 4 "arg2 = %arg2%" -@call :log 4 "rest = %rest%" -@call :log 4 "src = %~f0" -@if /i "%arg2%" == "call" ( - set script_source=cli -) else ( - @if /i "%arg1%" == "/c" ( - set script_source=explorer - ) else ( - set script_source=cli - ) -) -@call :log 3 "The script was invoked from %script_source%" -@endlocal & set "%~1=%script_source%" -@goto :eof - -:architecture - Finds the system architecture -:: %1 - The return variable [x86|x86_64] -@setlocal -@call :log 3 "Determining the processor architecture" -@set "key=HKLM\System\CurrentControlSet\Control\Session Manager\Environment" -@set "var=PROCESSOR_ARCHITECTURE" -@for /f "skip=2 tokens=2,*" %%a in ('reg query "%key%" /v "%var%"') do @set "arch=%%b" -@if "%arch%" == "AMD64" set arch=x86_64 -@call :log 4 "arch = %arch%" -@endlocal & set "%~1=%arch%" -@goto :eof - -:md5 - Gets the MD5 checksum for a file -:: %1 - The hash -:: %2 - The file path -@setlocal -@set var=%~1 -@set file_path=%~2 -@if [%var%] == [] exit /b 1 -@if "%file_path%" == "" exit /b 1 -@if not exist "%file_path%" exit /b 1 -@for /f "skip=3 tokens=1,*" %%a in ('powershell Get-FileHash -Algorithm MD5 "'%file_path%'"') do @set hash=%%b -@if not defined hash ( - call :log 6 - call :log 0 "Failed to get MD5 hash for %file_path%" - exit /b 1 -) -@endlocal & set "%var%=%hash: =%" -@goto :eof - -:windows_version - Checks the windows version -:: %1 - The windows version -:: %2 - The major version number return variable -:: %3 - The minor version number return variable -:: %4 - The revision version number return variable -@setlocal -@call :log 3 "Retrieving the Windows version" -@for /f "tokens=2 delims=[]" %%x in ('ver') do @set win_ver=%%x -@set win_ver=%win_ver:Version =% -@set win_ver_major=%win_ver:~0,1% -@set win_ver_minor=%win_ver:~2,1% -@set win_ver_rev=%win_ver:~4% -@call :log 4 "win_ver = %win_ver%" -@endlocal & set "%~1=%win_ver%" ^ - & set "%~2=%win_ver_major%" ^ - & set "%~3=%win_ver_minor%" ^ - & set "%~4=%win_ver_rev%" -@goto :eof - -:find_in_path - Finds a program of file in the PATH -@setlocal -@set var=%~1 -@set file=%~2 -@if [%var%] == [] exit /b 1 -@if [%file%] == [] exit /b 1 -@call :log 3 "Searching PATH for %file%" -@for %%x in ("%file%") do @set "file_path=%%~f$PATH:x" -@if not defined file_path exit /b 1 -@endlocal & set "%var%=%file_path%" -@goto :eof - -:administrator_check - Checks for administrator priviledges -@setlocal -@call :log 2 "Checking for administrator priviledges" -@set "key=HKLM\Software\VCA\Tool Chain\Admin Check" -@reg add "%key%" /v Elevated /t REG_DWORD /d 1 /f > nul 2>&1 -@if errorlevel 1 exit /b 1 -@reg delete "%key%" /va /f > nul 2>&1 -@endlocal -@goto :eof - -:log_append - Appends another file into the current logging file -:: %1 - the file_path to the file to concatenate -@setlocal -@set "file_path=%~1" -@if [%file_path%] == [] exit /b 1 -@call :log 3 "Appending to log: %file_path%" -@call :iso8601 iso8601 -@set "temp_log=%temp%\append-%iso8601%.log" -@call :log 4 "Using temp file %temp_log%" -@type "%log_path%" "%file_path%" > "%temp_log%" 2>nul -@move /y "%temp_log%" "%log_path%" 1>nul -@del "%file_path%" 2>nul -@del "%temp_log%" 2>nul -@endlocal -@goto :eof - -:iso8601 - Returns the current time in ISO8601 format -:: %1 - the return variable -:: %2 - format [extended|basic*] -:: iso8601 - contains the resulting timestamp -@setlocal -@wmic Alias /? >NUL 2>&1 || @exit /b 1 -@set "var=%~1" -@if "%var%" == "" @exit /b 1 -@set "format=%~2" -@if "%format%" == "" set format=basic -@for /F "skip=1 tokens=1-6" %%g IN ('wmic Path Win32_UTCTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:table') do @( - @if "%%~l"=="" goto :iso8601_done - @set "yyyy=%%l" - @set "mm=00%%j" - @set "dd=00%%g" - @set "hour=00%%h" - @set "minute=00%%i" - @set "seconds=00%%k" -) -:iso8601_done -@set mm=%mm:~-2% -@set dd=%dd:~-2% -@set hour=%hour:~-2% -@set minute=%minute:~-2% -@set seconds=%seconds:~-2% -@if /i [%format%] == [extended] ( - set iso8601=%yyyy%-%mm%-%dd%T%hour%:%minute%:%seconds%Z -) else ( - if /i [%format%] == [basic] ( - set iso8601=%yyyy%%mm%%dd%T%hour%%minute%%seconds%Z - ) else ( - @exit /b 1 - ) -) -@set iso8601=%iso8601: =0% -@endlocal & set %var%=%iso8601% -@goto :eof - -:verbosity - Processes the verbosity parameter '/v[v...] -:: %1 - verbosity given on the command line -:: logging_level - set to the number of v's -@setlocal -@set logging_level=0 -@set verbosity=%~1 -:verbosity_loop -@set verbosity=%verbosity:~1% -@if not [%verbosity%] == [] @( - set /a "logging_level=logging_level+1" - goto verbosity_loop -) -@endlocal & set logging_level=%logging_level% -@goto :eof - -:log - Logs a message, depending on verbosity -:: %1 - level -:: [0-4] for CLI logging -:: [5-9] for GUI logging -:: %2 - message to print -@setlocal -@set "level=%~1" -@set "msg=%~2" -@if "%log_folder%" == "" ( - echo Logging was used to early in the script, log_folder isn't set yet - goto :eof -) -@if "%log_path%" == "" ( - echo Logging was used to early in the script, log_path isn't set yet - goto :eof -) -@if not exist "%log_folder%" mkdir "%log_folder%" -@if not exist "%log_path%" echo. 1>nul 2>"%log_path%" -@echo.%msg% >> "%log_path%" -@if %level% geq 5 ( - @if [%script_source%] == [explorer] ( - set /a "level=level-5" - ) else ( - @goto :eof - ) -) -@if "%logging_level%" == "" ( - echo Logging was used to early in the script, logging_level isn't set yet - goto :eof -) -@if %logging_level% geq %level% echo.%msg% 1>&2 -@endlocal -@goto :eof - - -:start_browser - Opens the default browser to a URL -:: %1 - the url to open -@setlocal -@set url=%~1 -@call :log 4 "Opening default browser: %url%" -@start %url% -@endlocal -@goto :eof - -:find_cmake - Finds cmake on the command line or in the registry -:: %1 - the cmake file path -@setlocal -@set var=%~1 -@if [%var%] == [] exit /b 1 -@call :log 6 -@call :log 6 "Finding CMake" -@call :log 6 "--------------" -@call :find_in_path cmake_executable cmake.exe -@if not errorlevel 1 goto found_cmake -@for /l %%i in (5,-1,0) do @( -@for /l %%j in (9,-1,0) do @( -@for /l %%k in (9,-1,0) do @( -@for %%l in (HKCU HKLM) do @( -@for %%m in (SOFTWARE SOFTWARE\Wow6432Node) do @( - @reg query "%%l\%%m\Kitware\CMake %%i.%%j.%%k" /ve > nul 2>nul - @if not errorlevel 1 ( - @for /f "skip=2 tokens=2,*" %%a in ('reg query "%%l\%%m\Kitware\CMake %%i.%%j.%%k" /ve') do @( - @if exist "%%b\bin\cmake.exe" ( - @set "cmake_executable=%%b\bin\cmake.exe" - goto found_cmake - ) - ) - ) -))))) -@call :log 5 -@call :log 0 "Failed to find cmake" -@exit /b 1 -:found_cmake -@endlocal & set "%var%=%cmake_executable%" -@goto :eof - -:cmake - Finds cmake and installs it if necessary -:: %1 - the cmake file path -@setlocal -@set var=%~1 -@if [%var%] == [] exit /b 1 -@call :log 6 -@call :log 6 "Checking for CMake" -@call :log 6 "------------------" -@call :find_cmake cmake_executable cmake.exe -@if not errorlevel 1 goto got_cmake -@set checksum=C00267A3D3D9619A7A2E8FA4F46D7698 -@set version=3.2.2 -@call :install_nsis cmake http://www.cmake.org/files/v%version:~0,3%/cmake-%version%-win32-x86.exe %checksum% -@if errorlevel 1 ( - call :log 5 - call :log 0 "Failed to install cmake" - @exit /b 1 -) -@call :find_cmake cmake_executable cmake.exe -@if not errorlevel 1 goto got_cmake -@call :log 5 -@call :log 0 "Failed to check for cmake" -@exit /b 1 -:got_cmake -@endlocal & set "%var%=%cmake_executable%" -@goto :eof - -:mingw - Finds MinGW, installing it if needed -:: %1 - the compiler path that should be added to PATH -@setlocal EnableDelayedExpansion -@if errorlevel 1 ( - @call :log 5 - @call :log 0 "Failed to enable extensions" - @exit /b 1 -) -@set var=%~1 -@if [%var%] == [] exit /b 1 -@call :log 6 -@call :log 6 "Checking for MinGW" -@call :log 6 "------------------" -@call :find_in_path gcc_executable gcc.exe -@if not errorlevel 1 ( - @for %%a in ("%gcc_executable%") do @set "compiler_path=%%~dpa" - goto got_mingw -) -@call :log 7 -@call :log 2 "Downloading MinGW" -@if %logging_level% leq 1 set "logging=/q" -@if %logging_level% gtr 1 set "logging=/v" -@set output_path= -@for /f %%a in ('call - "%script_folder%\mingw.cmd" - %logging% - /arch "%arch%" - "%dependency_path%"' -) do @set "compiler_path=%%a\" -@if not defined compiler_path ( - @call :log_append "%output%" - @call :log 5 - @call :log 0 "Failed to download MinGW" - @exit /b 1 -) -:got_mingw -@call :log 5 -@call :log 0 "Found MinGW: %compiler_path%gcc.exe" -@endlocal & set "%var%=%compiler_path%" -@goto :eof - -:msbuild - Finds MSBuild -:: %1 - the path to MSBuild executable -@setlocal -@set var=%~1 -@if [%var%] == [] exit /b 1 -@call :find_in_path msbuild_executable msbuild.exe -@if not errorlevel 1 goto got_msbuild -@for /l %%i in (20,-1,4) do @( -@for /l %%j in (9,-1,0) do @( -@for %%k in (HKCU HKLM) do @( -@for %%l in (SOFTWARE SOFTWARE\Wow6432Node) do @( - @reg query "%%k\%%l\Microsoft\MSBuild\%%i.%%j" /v MSBuildOverrideTasksPath > nul 2>nul - @if not errorlevel 1 ( - @for /f "skip=2 tokens=2,*" %%a in ('reg query "%%k\%%l\Microsoft\MSBuild\%%i.%%j" /v MSBuildOverrideTasksPath') do @( - @if exist "%%bmsbuild.exe" ( - @set "msbuild_executable=%%bmsbuild.exe" - goto got_msbuild - ) - ) - ) -)))) -@call :log 5 -@call :log 0 "Failed to check for MSBuild" -@exit /b 1 -:got_msbuild -@endlocal & set "%var%=%msbuild_executable%" -@goto :eof - -:download - Downloads a file from the internet -:: %1 - the url of the file to download -:: %2 - the file to download to -:: %3 - the MD5 checksum of the file (optional) -@setlocal EnableDelayedExpansion -@if errorlevel 1 ( - call :print_usage "Failed to enable extensions" - exit /b 1 -) -@set url=%~1 -@set file_path=%~2 -@set checksum=%~3 -@for %%a in (%file_path%) do @set dir_path=%%~dpa -@for %%a in (%file_path%) do @set file_name=%%~nxa -@if [%url%] == [] exit /b 1 -@if [%file_path%] == [] exit /b 1 -@if [%dir_path%] == [] exit /b 1 -@if [%file_name%] == [] exit /b 1 -@if not exist "%dir_path%" mkdir "%dir_path%" -@call :log 1 "Downloading %url%" -@call :iso8601 iso8601 -@set temp_path=%temp%\download-%iso8601%-%file_name% -@call :log 3 "Using temp file %temp_path%" -@powershell Invoke-WebRequest "%url%" -OutFile %temp_path% -@if errorlevel 1 ( - call :log 0 "Failed to download %url%" - exit /b 1 -) -@if [%checksum%] neq [] ( - @call :log 4 "Checking %checksum% against %temp_path%" - @call :md5 hash "%temp_path%" - if "!hash!" neq "%checksum%" ( - call :log 0 "Failed to match checksum: %temp_path%" - call :log 0 "Hash : !hash!" - call :log 0 "Checksum: %checksum%" - exit /b 1 - ) else ( - call :log 3 "Checksum matched: %temp_path%" - call :log 3 "Hash : !hash!" - call :log 3 "Checksum: %checksum%" - ) -) -@call :log 4 "Renaming %temp_path% to %file_path%" -@move /y "%temp_path%" "%file_path%" 1>nul -@endlocal -@goto :eof - -:install_msi - Installs a dependency from an Microsoft Installer package (.msi) -:: %1 - [string] name of the project to install -:: %2 - The location of the .msi, a url must start with 'http://' or file_path -:: %3 - The checksum of the msi (optional) -@setlocal -@set name=%~1 -@set file_path=%~2 -@set checksum=%~3 -@set msi=%~nx2 -@set msi_path=%dependency_path%\%msi% -@if [%name%] == [] exit /b 1 -@if [%file_path%] == [] exit /b 1 -@if [%msi%] == [] exit /b 1 -@if [%msi_path%] == [] exit /b 1 -@for %%x in (msiexec.exe) do @set "msiexec_path=%%~f$PATH:x" -@if "msiexec_path" == "" ( - call :log 0 "Failed to find the Microsoft package installer (msiexec.exe)" - call :log 6 - call :log 0 "Please install it from the Microsoft Download center" - call :log 6 - choice /C YN /T 60 /D N /M "Would you like to go there now?" - if !errorlevel! equ 1 call :start_browser ^ - "http://search.microsoft.com/DownloadResults.aspx?q=Windows+Installer" - exit /b 1 -) -@call :log 6 -@call :log 1 "Installing the '%name%' dependency" -@call :log 6 "-------------------------------------" -@call :administrator_check -@if errorlevel 1 ( - call :log 0 "You must run %~nx0 in elevated mode to install '%name%'" - call :log 5 "Right-Click and select 'Run as Administrator' - call :log 0 "Install the dependency manually by running %file_path%" - @exit /b 740 -) -@if [%file_path:~0,4%] == [http] ( - if not exist "%msi_path%" ( - call :download "%file_path%" "%msi_path%" %checksum% - if errorlevel 1 ( - call :log 0 "Failed to download the %name% dependency" - exit /b 1 - ) - ) -) else ( - call :log 2 "Copying MSI %file_path% to %msi_path%" - call :log 7 - if not exist "%msi_path%" ( - xcopy /q /y /z "%file_path%" "%msi_path%" 1>nul - if errorlevel 1 ( - call :log 0 "Failed to copy the Microsoft Installer" - exit /b 1 - ) - ) -) -@call :log 1 "Running the %msi%" -@call :log 6 -@set msi_log=%temp%\msiexec-%timestamp%.log -@call :log 3 "Logging to: %msi_log%" -@msiexec /i "%msi_path%" /passive /log "%msi_log%" ALLUSERS=1 -@set msi_errorlevel=%errorlevel% -@call :log_append "%msi_log%" -@if %msi_errorlevel% equ 0 goto install_msi_success -@if %msi_errorlevel% equ 3010 goto install_msi_success_reboot -@if %msi_errorlevel% equ 1641 goto install_msi_success_reboot -@if %msi_errorlevel% equ 3015 goto install_msi_in_progress_reboot -@if %msi_errorlevel% equ 1615 goto install_msi_in_progress_reboot -@call :log 0 "Microsoft Installer failed: %msi_errorlevel%" -@call :log 0 "Install the dependency manually by running %msi_path%" -@exit /b 1 -:install_msi_in_progress_reboot -@call :log 0 "The installation requires a reboot to continue" -@call :log 5 -@call :reboot -@exit /b 1 -:install_msi_success_reboot -@call :log 3 "The installation requires a reboot to be fully functional" -@set reboot_required=1 -:install_msi_success -@call :log 2 "Successfully installed %name%" -@call :log 7 -@endlocal & set reboot_required=%reboot_required% -@goto :eof - -:install_nsis - Installs a dependency from an Nullsoft Installer package (.exe) -:: %1 - [string] name of the project to install -:: %2 - The location of the .exe, a url must start with 'http://' or file_path -:: %3 - The checksum of the exe (optional) -@setlocal -@set name=%~1 -@set file_path=%~2 -@set checksum=%~3 -@set exe=%~nx2 -@set exe_path=%dependency_path%\%exe% -@if [%name%] == [] exit /b 1 -@if [%file_path%] == [] exit /b 1 -@if [%exe%] == [] exit /b 1 -@if [%exe_path%] == [] exit /b 1 -@call :log 6 -@call :log 1 "Installing the '%name%' dependency" -@call :log 6 "-------------------------------------" -@call :administrator_check -@if errorlevel 1 ( - call :log 0 "You must run %~nx0 in elevated mode to install '%name%'" - call :log 5 "Right-Click and select 'Run as Administrator' - call :log 0 "Install the dependency manually by running %file_path%" - @exit /b 740 -) -@if [%file_path:~0,4%] == [http] ( - if not exist "%exe_path%" ( - call :download "%file_path%" "%exe_path%" %checksum% - if errorlevel 1 ( - call :log 0 "Failed to download the %name% dependency" - exit /b 1 - ) - ) -) else ( - call :log 2 "Copying installer %file_path% to %exe_path%" - call :log 7 - if not exist "%exe_path%" ( - xcopy /q /y /z "%file_path%" "%exe_path%" 1>nul - if errorlevel 1 ( - call :log 0 "Failed to copy the Nullsoft Installer" - exit /b 1 - ) - ) -) -@call :log 1 "Running the %exe%" -@call :log 6 -@"%exe_path%" /S -@set nsis_errorlevel=%errorlevel% -@if %nsis_errorlevel% equ 0 goto install_nsis_success -@if %nsis_errorlevel% equ 3010 goto install_nsis_success_reboot -@if %nsis_errorlevel% equ 1641 goto install_nsis_success_reboot -@if %nsis_errorlevel% equ 3015 goto install_nsis_in_progress_reboot -@if %nsis_errorlevel% equ 1615 goto install_nsis_in_progress_reboot -@call :log 0 "Nullsoft Installer failed: %nsis_errorlevel%" -@call :log 0 "Install the dependency manually by running %exe_path%" -@exit /b 1 -:install_nsis_in_progress_reboot -@call :log 0 "The installation requires a reboot to continue" -@call :log 5 -@call :reboot -@exit /b 1 -:install_nsis_success_reboot -@call :log 3 "The installation requires a reboot to be fully functional" -@set reboot_required=1 -:install_nsis_success -@call :log 2 "Successfully installed %name%" -@call :log 7 -@endlocal & set reboot_required=%reboot_required% -@goto :eof - -:reboot - Asks the user if they would like to reboot then stops the script -@setlocal -@call :log 6 "-------------------------------------------" -@choice /C YN /T 60 /D N /M "The %method% requires a reboot, reboot now?" -@set ret=%errorlevel% -@call :log 6 -@if %ret% equ 1 ( - @shutdown /r -) else ( - @call :log 0 "You will need to reboot to complete the %method%" - @call :log 5 -) -@endlocal -@goto :eof diff --git a/docs/APIReference.md b/docs/APIReference.md index 96f5c895..72141b93 100644 --- a/docs/APIReference.md +++ b/docs/APIReference.md @@ -1,7 +1,7 @@ -# CivetWeb API Reference +# Libhttp API Reference -CivetWeb is often used as HTTP and HTTPS library inside a larger application. -A C API is available to integrate the CivetWeb functionality in a larger +Libhttp is often used as HTTP and HTTPS library inside a larger application. +A C API is available to integrate the Libhttp functionality in a larger codebase. A C++ wrapper is also available, although it is not guaranteed that all functionality available through the C API can also be accessed from C++. This document describes the public C API. Basic usage examples of @@ -43,7 +43,6 @@ the API can be found in [Embedding.md](Embedding.md). * [`mg_get_server_ports( ctx, size, ports );`](api/mg_get_server_ports.md) * [`mg_get_user_connection_data( conn );`](api/mg_get_user_connection_data.md) * [`mg_get_user_data( ctx );`](api/mg_get_user_data.md) -* [~~`mg_get_valid_option_names();`~~](api/mg_get_valid_option_names.md) * [`mg_get_valid_options();`](api/mg_get_valid_options.md) * [`mg_get_var( data, data_len, var_name, dst, dst_len );`](api/mg_get_var.md) * [`mg_get_var2( data, data_len, var_name, dst, dst_len, occurrence );`](api/mg_get_var2.md) @@ -69,7 +68,6 @@ the API can be found in [Embedding.md](Embedding.md). * [`mg_strncasecmp( s1, s2, len );`](api/mg_strncasecmp.md) * [`mg_unlock_connection( conn );`](api/mg_unlock_connection.md) * [`mg_unlock_context( ctx );`](api/mg_unlock_context.md) -* [~~`mg_upload( conn, destination_dir );`~~](api/mg_upload.md) * [`mg_url_decode( src, src_len, dst, dst_len, is_form_url_encoded );`](api/mg_url_decode.md) * [`mg_url_encode( src, dst, dst_len );`](api/mg_url_encode.md) * [`mg_version();`](api/mg_version.md) diff --git a/docs/Building.md b/docs/Building.md index 9668f61b..6ed26194 100644 --- a/docs/Building.md +++ b/docs/Building.md @@ -1,44 +1,21 @@ -Building CivetWeb +Building LibHTTP ========= This guide covers the build instructions for the stand-alone web server. -See [Embedding.md](https://github.com/civetweb/civetweb/blob/master/docs/Embedding.md) for information on extending an existing C or C++ application. A brief overview of the source code files can be found in [Embedding.md](https://github.com/civetweb/civetweb/blob/master/docs/Embedding.md) as well. +See [Embedding.md](Embedding.md) for information on extending an existing C or C++ application. A brief overview of the source code files can be found in [Embedding.md](Embedding.md) as well. #### Where to get the source code? The latest version can be found at -https://github.com/civetweb/civetweb +https://github.com/lammertb/libhttp Released versions can be found at -https://github.com/civetweb/civetweb/releases +https://github.com/lammertb/libhttp/releases -Building for Windows ---------- - -#### Using Visual Studio - -Open the *VS/civetweb.sln* in Visual Studio. -To include SSL support, you may have to add an extra library for the cryptography support. You might wish to use yaSSL. However, it is GPL licensed or uses a commercial license. See [yaSSL.md](https://github.com/civetweb/civetweb/blob/master/docs/yaSSL.md) for more information. -Alternatively, you might wish to use OpenSSL. See [OpenSSL.md](https://github.com/civetweb/civetweb/blob/master/docs/OpenSSL.md) for more information. - -#### Using MinGW-w64 or TDM-GCC -In the start menu locate and run the "Run terminal" batch file. For TDM-GCC this is named "MinGW Command Prompt". -Navigate to the civetweb sources directory and run: -``` -mingw32-make CC=gcc -``` - -#### Using Qt Creator -Open the Qt Designer project in the Qt folder - -#### Using CMake -Except for the components in the `third_party` folder (e.g., Lua and Duktape), CivetWeb can also be built with CMake. -CMake can be used for all supported operating systems. - - -Building for Linux, BSD, and OSX +Building for Windows, Linux, BSD, OSX --------- +Builds for all operating systems are created with GNU Make. ## Using Make @@ -62,7 +39,7 @@ make lib WITH_CPP=1 WITH_IPV6=1 make clean slib WITH_CPP=1 WITH_LUA=1 WITH_WEBSOCKET=1 ``` Build the static and shared libraries. -The *WITH_CPP* make option is to include the CivetServer class. +The *WITH_CPP* make option is to include the LibHTTPServer class. The additional make options configure the library just as it would the application. The *slib* option should be done on a separate clean build as position @@ -143,37 +120,21 @@ one additional *package* rule. make -f Makefile.osx package ``` -Building with Buildroot ---------- - -[Buildroot](http://buildroot.uclibc.org/) is a tool for creating cross compiled file systems. Including Civetweb in buildroot is fairly easy. There is even support for various build options. - -1. First, check if it already there. - - In buildroot, make menuconfig - - Package Selection for the target ---> - - Networking applications ---> - - civetweb -2. If not there, just add it - - copy *Config.in* and *civetweb.mk* from Civetweb's *contrib/buildroot/* to Buildroot's *package/civetweb/* directory. - - In Buildroot's *package/Config.in, insert the following line in were you will know how to find it in the menu. - > ``` source "package/civetweb/Config.in" ``` - - Building on Android --------- -This is a small guide to help you run civetweb on Android. Currently it is +This is a small guide to help you run LibHTTP on Android. Currently it is tested on the HTC Wildfire. If you have managed to run it on other devices as well, please comment or drop an email in the mailing list. -Note: You do not need root access to run civetweb on Android. +Note: You do not need root access to run LibHTTP on Android. - Download the source from the Downloads page. - Download the Android NDK from [http://developer.android.com/tools/sdk/ndk/index.html](http://developer.android.com/tools/sdk/ndk/index.html) -- Run `/path-to-ndk/ndk-build -C /path-to-civetweb/resources` - That should generate civetweb/lib/armeabi/civetweb +- Run `/path-to-ndk/ndk-build -C /path-to-libhttp/resources` + That should generate libhttp/lib/armeabi/libhttp - Using the adb tool (you need to have Android SDK installed for that), - push the generated civetweb binary to `/data/local` folder on device. -- From adb shell, navigate to `/data/local` and execute `./civetweb`. + push the generated libhttp binary to `/data/local` folder on device. +- From adb shell, navigate to `/data/local` and execute `./libhttp`. - To test if the server is running fine, visit your web-browser and navigate to `http://127.0.0.1:8080` You should see the `Index of /` page. @@ -183,7 +144,7 @@ Note: You do not need root access to run civetweb on Android. Notes: - `jni` stands for Java Native Interface. Read up on Android NDK if you want - to know how to interact with the native C functions of civetweb in Android + to know how to interact with the native C functions of libhttp in Android Java applications. - TODO: A Java application that interacts with the native binary or a shared library. diff --git a/docs/Contribution.md b/docs/Contribution.md index de3ff437..8a88cacf 100644 --- a/docs/Contribution.md +++ b/docs/Contribution.md @@ -1,9 +1,9 @@ -Contributing to CivetWeb +Contributing to LibHTTP ==== -Contributions to CivetWeb are welcome, provided all contributions carry the MIT license. +Contributions to LibHTTP are welcome, provided all contributions carry the MIT license. -- Please first create an issue on GitHub or create a thread on the CivetWeb discussion group. +- Please first create an issue on GitHub. - If possible, create a pull request on GitHub. Please take care your modifications pass the continuous integration checks. These checks are performed automatically when you create a pull request, but it may take some hours until all tests are completed. - Alternatively, you can post a patch. However, pull requests are preferred. - Contributor names are listed in CREDITS.md, unless you explicitly state you don't want your name to be listed there. diff --git a/docs/Embedding.md b/docs/Embedding.md index 3f2a2db9..70947831 100644 --- a/docs/Embedding.md +++ b/docs/Embedding.md @@ -1,38 +1,38 @@ -Embedding CivetWeb +Embedding LibHTTP ========= -CivetWeb is primarily designed so applications can easily add HTTP and HTTPS server as well as WebSocket functionality. For example, an application server could use CivetWeb to enable a web service interface for automation or remote control. +LibHTTP is primarily designed so applications can easily add HTTP and HTTPS server as well as WebSocket functionality. For example, an application server could use LibHTTP to enable a web service interface for automation or remote control. -However, it can also be used as a stand-alone executable. It can deliver static files and offers built-in server side Lua, JavaScript and CGI support. Some instructions how to build the stand-alone server can be found in [Building.md](https://github.com/civetweb/civetweb/blob/master/docs/Building.md). +However, it can also be used as a stand-alone executable. It can deliver static files and offers built-in server side Lua, JavaScript and CGI support. Some instructions how to build the stand-alone server can be found in [Building.md](Building.md). Files ------ There is just a small set of files to compile in to the application, -but if a library is desired, see [Building.md](https://github.com/CivetWeb/CivetWeb/blob/master/docs/Building.md) +but if a library is desired, see [Building.md](Building.md) #### Regarding the INL file extension -The *INL* file extension represents code that is statically included inline in a source file. Slightly different from C++ where it means "inline" code which is technically not the same as static code. CivetWeb overloads this extension for the sake of clarity as opposed to having .c extensions on files that should not be directly compiled. +The *INL* file extension represents code that is statically included inline in a source file. Slightly different from C++ where it means "inline" code which is technically not the same as static code. LibHTTP overloads this extension for the sake of clarity as opposed to having .c extensions on files that should not be directly compiled. #### HTTP Server Source Files -These files constitute the CivetWeb library. They do not contain a `main` function, +These files constitute the LibHTTP library. They do not contain a `main` function, but all functions required to run a HTTP server. - HTTP server API - - include/civetweb.h + - include/libhttp.h - C implementation - - src/civetweb.c + - src/libhttp.c - src/md5.inl (MD5 calculation) - src/handle_form.inl (HTML form handling functions) - Optional: C++ wrapper - - include/CivetServer.h (C++ interface) - - src/CivetServer.cpp (C++ wrapper implementation) + - include/LibHTTPServer.h (C++ interface) + - src/LibHTTPServer.cpp (C++ wrapper implementation) - Optional: Third party components - src/third_party/* (third party components, mainly used for the standalone server) - - src/mod_*.inl (modules to access third party components from civetweb) + - src/mod_*.inl (modules to access third party components from LibHTTP) -Note: The C++ wrapper uses the official C interface (civetweb.h) and does not add new features to the server. Some features available in the C interface might be missing in the C++ interface. +Note: The C++ wrapper uses the official C interface (libhttp.h) and does not add new features to the server. Some features available in the C interface might be missing in the C++ interface. #### Additional Source Files for Executables @@ -54,7 +54,7 @@ Quick Start By default, the server will automatically serve up files like a normal HTTP server. An embedded server is most likely going to overload this functionality. ### C - - Include the C interface ```civetweb.h```. + - Include the C interface ```libhttp.h```. - Use `mg_start()` to start the server. - Use *options* to select the port and document root among other things. - Use *callbacks* to add your own hooks. @@ -62,11 +62,11 @@ By default, the server will automatically serve up files like a normal HTTP serv - Use `mg_stop()` to stop the server. ### C++ - - Note that CivetWeb is Clean C, and C++ interface ```CivetServer.h``` is only a wrapper layer around the C interface. - Not all CivetWeb features available in C are also available in C++. - - Create CivetHandlers for each URI. - - Register the handlers with `CivetServer::addHandler()` - - `CivetServer` starts on contruction and stops on destruction. + - Note that LibHTTP is Clean C, and C++ interface ```LibHTTPServer.h``` is only a wrapper layer around the C interface. + Not all LibHTTP features available in C are also available in C++. + - Create LibHTTPHandlers for each URI. + - Register the handlers with `LibHTTPServer::addHandler()` + - `LibHTTPServer` starts on contruction and stops on destruction. - Use contructor *options* to select the port and document root among other things. - Use constructor *callbacks* to add your own hooks. @@ -130,17 +130,17 @@ This build is valid for Lua version Lua 5.2. It is also possible to build with L JavaScript Support ------ -CivetWeb can be built with server side JavaScript support by including the Duktape library. +LibHTTP can be built with server side JavaScript support by including the Duktape library. -CivetWeb internals +LibHTTP internals ------ -CivetWeb is multithreaded web server. `mg_start()` function allocates +LibHTTP is multithreaded web server. `mg_start()` function allocates web server context (`struct mg_context`), which holds all information about web server instance: -- configuration options. Note that CivetWeb makes internal copies of +- configuration options. Note that LibHTTP makes internal copies of passed options. - SSL context, if any - user-defined callbacks @@ -153,11 +153,11 @@ When `mg_start()` returns, all initialization is guaranteed to be complete some threads: a master thread, that accepts new connections, and several worker threads, that process accepted connections. The number of worker threads is configurable via `num_threads` configuration option. That number puts a -limit on number of simultaneous requests that can be handled by CivetWeb. -If you embed CivetWeb into a program that uses SSL outside CivetWeb as well, +limit on number of simultaneous requests that can be handled by LibHTTP. +If you embed LibHTTP into a program that uses SSL outside LibHTTP as well, you may need to initialize SSL before calling `mg_start()`, and set the pre- processor define SSL_ALREADY_INITIALIZED. This is not required if SSL is used -only within CivetWeb. +only within LibHTTP. When master thread accepts new a connection, a new accepted socket (described by `struct socket`) it placed into the accepted sockets queue, @@ -180,7 +180,7 @@ looks something like this: } } -Function `consume_socket()` gets a new accepted socket from the CivetWeb socket +Function `consume_socket()` gets a new accepted socket from the LibHTTP socket queue, atomically removing it from the queue. If the queue is empty, `consume_socket()` blocks and waits until a new socket is placed in the queue by the master thread. @@ -195,6 +195,6 @@ listening sockets. `poll()` is used to avoid `FD_SETSIZE` limitation of to use hi-performance alternatives like `epoll()` or `kqueue()`. Worker threads use blocking IO on accepted sockets for reading and writing data. All accepted sockets have `SO_RCVTIMEO` and `SO_SNDTIMEO` socket options set -(controlled by the `request_timeout_ms` CivetWeb option, 30 seconds default) +(controlled by the `request_timeout_ms` LibHTTP option, 30 seconds default) which specifies a read/write timeout on client connections. diff --git a/docs/Installing.md b/docs/Installing.md index d5e87cc9..537c20fe 100644 --- a/docs/Installing.md +++ b/docs/Installing.md @@ -1,36 +1,6 @@ -Civetweb Install Guide +LibHTTP Install Guide ==== -This guide covers the distributions for CivetWeb. The latest source code is available at [https://github.com/civetweb/civetweb](https://github.com/civetweb/civetweb). +This guide covers the distributions for LibHTTP. The latest source code is available at [https://github.com/lammertb/libhttp](https://github.com/lammertb/libhttp). -Windows ---- - -This pre-built version comes pre-built wit Lua support. Libraries for SSL support are not included due to licensing restrictions; -however, users may add an SSL library themselves. -Instructions for adding SSL support can be found in [https://github.com/civetweb/civetweb/tree/master/docs](https://github.com/civetweb/civetweb/tree/master/docs) - -1a. 32 Bit: Install the [Visual C++ Redistributable for Visual Studio 2010](http://www.microsoft.com/en-us/download/details.aspx?id=8328) -1b. 64 Bit: Install the [Visual C++ Redistributable for Visual Studio 2013](http://www.microsoft.com/en-us/download/details.aspx?id=40784) -2. Download latest *civetweb-win.zip* from [SourceForge](https://sourceforge.net/projects/civetweb/files/) -3. When started, Civetweb puts itself into the tray. - -OS X ---- - -This pre-built version comes with Lua, IPV6 and SSL support. - -1. Download the latest *Civetweb.dmg* from [SourceForge](https://sourceforge.net/projects/civetweb/files/) -2. Click on the it and look for the attachment in the finder. -4. Drag Civetweb to the Applications folder. -5. When started, Civetweb puts itself into top menu. - -Linux ---- - -1. Download the latest *civetweb.tar.gz* from [SourceForge](https://sourceforge.net/projects/civetweb/files/) -2. Open archive and change to the new directory. -3. make help -4. make -5. make install -6. Run the program ```/usr/local/bin/civetweb```, it will use the configuration file */usr/local/etc/civetweb.conf*. +Installing is as simple as downloading the sources and typing `make` on the command line in the root of the project directory. diff --git a/docs/OpenSSL.md b/docs/OpenSSL.md index 1f01cca7..d210d73b 100644 --- a/docs/OpenSSL.md +++ b/docs/OpenSSL.md @@ -1,7 +1,7 @@ Adding OpenSSL Support ===== -Civetweb supports *HTTPS* connections using the OpenSSL transport layer +LibHTTP supports *HTTPS* connections using the OpenSSL transport layer security (TLS) library. OpenSSL is a free, open source library (see http://www.openssl.org/). @@ -11,17 +11,17 @@ Getting Started - Install OpenSSL on your system. There are OpenSSL install packages for all major Linux distributions as well as a setup for Windows. -- The default build configuration of the civetweb web server will load the +- The default build configuration of the LibHTTP web server will load the required OpenSSL libraries, if a HTTPS certificate has been configured. -Civetweb Configuration +LibHTTP Configuration ---- The configuration file must contain an https port, identified by a letter 's' attached to the port number. To serve http and https from their standard ports use the following line in -the configuration file 'civetweb.conf': +the configuration file 'libhttp.conf':
   listening_ports 80, 443s
 
@@ -32,7 +32,7 @@ To serve only https use: Furthermore the SSL certificate file must be set:
-  ssl_certificate d:\civetweb\certificate\server.pem
+  ssl_certificate d:\libhttp\certificate\server.pem
 
@@ -40,7 +40,7 @@ Creating a self signed certificate ---- OpenSSL provides a command line interface, that can be used to create the -certificate file required by civetweb (server.pem). +certificate file required by LibHTTP (server.pem). One can use the following steps in Windows (in Linux replace "copy" by "cp" and "type" by "cat"): @@ -102,7 +102,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Including a certificate from a certificate authority ---- -CivetWeb requires one certificate file in PEM format. +LibHTTP requires one certificate file in PEM format. If you got multiple files from your certificate authority, you need to copy their content together into one file. Make sure the file has one section BEGIN RSA PRIVATE KEY / @@ -124,7 +124,7 @@ Common Problems ---- In case the OpenSSL configuration is not set up correctly, the server will not -start. Configure an error log file in 'civetweb.conf' to get more information: +start. Configure an error log file in 'libhttp.conf' to get more information:
   error_log_file error.log
 
diff --git a/docs/UserManual.md b/docs/UserManual.md index 7f2943ba..9f594ac2 100644 --- a/docs/UserManual.md +++ b/docs/UserManual.md @@ -2,9 +2,9 @@ Overview ===== -Civetweb is small and easy to use web server. +LibHTTP is small and easy to use web server. It may be embedded into C/C++ host applications or used as a stand-alone -server. See `Embedding.md` for information on embedding civetweb into +server. See `Embedding.md` for information on embedding LibHTTP into host applications. The stand-alone server is self-contained, and does not require any external @@ -14,71 +14,71 @@ software to run. Some Windows users may need to install the Installation ---- -On Windows, UNIX and Mac, the civetweb stand-alone executable may be started +On Windows, UNIX and Mac, the LibHTTP stand-alone executable may be started from the command line. -Running `civetweb` in a terminal, optionally followed by configuration parameters -(`civetweb [OPTIONS]`) or a configuration file name (`civetweb [config_file_name]`), +Running `libhttp` in a terminal, optionally followed by configuration parameters +(`libhttp [OPTIONS]`) or a configuration file name (`libhttp [config_file_name]`), starts the web server. -For UNIX and Mac, civetweb does not detach from the terminal. +For UNIX and Mac, libhttp does not detach from the terminal. Pressing `Ctrl-C` keys will stop the server. -On Windows, civetweb iconifies itself to the system tray icon when started. +On Windows, LibHTTP iconifies itself to the system tray icon when started. Right-click on the icon pops up a menu, where it is possible to stop -civetweb, or configure it, or install it as Windows service. +LibHTTP, or configure it, or install it as Windows service. When started without options, the server exposes the local directory at [http](http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol) port 8080. -Thus, the easiest way to share a folder on Windows is to copy `civetweb.exe` +Thus, the easiest way to share a folder on Windows is to copy `libhttp.exe` to this folder, double-click the exe, and launch a browser at [http://localhost:8080](http://localhost:8080). Note that 'localhost' should be changed to a machine's name if a folder is accessed from other computer. -When started, civetweb first searches for the configuration file. +When started, LibHTTP first searches for the configuration file. If configuration file is specified explicitly in the command line, i.e. -`civetweb path_to_config_file`, then specified configuration file is used. -Otherwise, civetweb would search for file `civetweb.conf` in the same directory +`libhttp path_to_config_file`, then specified configuration file is used. +Otherwise, LibHTTP would search for file `libhttp.conf` in the same directory the executable is located, and use it. This configuration file is optional. The configuration file is a sequence of lines, each line containing one command line argument name and the corresponding value. Empty lines, and lines beginning with `#`, are ignored. -Here is the example of `civetweb.conf` file: +Here is the example of `libhttp.conf` file: document_root c:\www listening_ports 80,443s - ssl_certificate c:\civetweb\ssl_cert.pem + ssl_certificate c:\libhttp\ssl_cert.pem When a configuration file is used, additional command line arguments may override the configuration file settings. All command line arguments must start with `-`. -For example: The above `civetweb.conf` file is used, and civetweb started as -`civetweb -document_root D:\web`. Then the `D:\web` directory will be served +For example: The above `libhttp.conf` file is used, and LibHTTP started as +`libhttp -document_root D:\web`. Then the `D:\web` directory will be served as document root, because command line options take priority over the configuration file. The configuration options section below provides a good -overview of the Civetweb features. +overview of the LibHTTP features. Note that configuration options on the command line must start with `-`, but their names are the same as in the config file. All option names are listed in the next section. Thus, the following two setups are equivalent: # Using command line arguments - $ civetweb -listening_ports 1234 -document_root /var/www + $ libhttp -listening_ports 1234 -document_root /var/www # Using config file - $ cat civetweb.conf + $ cat libhttp.conf listening_ports 1234 document_root /var/www - $ civetweb + $libhttp -Civetweb can also be used to modify `.htpasswd` passwords files: +LibHTTP can also be used to modify `.htpasswd` passwords files: - civetweb -A + libhttp -A -Unlike other web servers, civetweb does not require CGI scripts to be located +Unlike other web servers, LibHTTP does not require CGI scripts to be located in a special directory. CGI scripts can be anywhere. CGI (and SSI) files are -recognized by the file name pattern. Civetweb uses shell-like glob +recognized by the file name pattern. LibHTTP uses shell-like glob patterns. Pattern match starts at the beginning of the string, so essentially patterns are prefix patterns. Syntax is as follows: @@ -96,7 +96,7 @@ All other characters in the pattern match themselves. Examples: # Configuration Options -Below is a list of configuration options understood by Civetweb. +Below is a list of configuration options understood by LibHTTP. Every option is followed by it's default value. If a default value is not present, then the default is empty. @@ -119,16 +119,16 @@ DELETE requests might still be handled by Lua scripts and CGI paged. ### cgi\_interpreter Path to an executable to use as CGI interpreter for __all__ CGI scripts regardless of the script file extension. If this option is not set (which is -the default), Civetweb looks at first line of a CGI script, +the default), LibHTTP looks at first line of a CGI script, [shebang line](http://en.wikipedia.org/wiki/Shebang_(Unix\)), for an interpreter (not only on Linux and Mac but also for Windows). For example, if both PHP and Perl CGIs are used, then `#!/path/to/php-cgi.exe` and `#!/path/to/perl.exe` must be first lines of the respective CGI scripts. Note that paths should be either full file paths, -or file paths relative to the current working directory of the civetweb -server. If civetweb is started by mouse double-click on Windows, the current -working directory is the directory where the civetweb executable is located. +or file paths relative to the current working directory of the LibHTTP +server. If LibHTTP is started by mouse double-click on Windows, the current +working directory is the directory where the LibHTTP executable is located. If all CGIs use the same interpreter, for example they are all PHP, it is more efficient to set `cgi_interpreter` to the path to `php-cgi.exe`. @@ -158,7 +158,7 @@ should end with a special extension, by default the extension should be either `.shtml` or `.shtm`. These extentions may be changed using the `ssi_pattern` option. -Unknown SSI directives are silently ignored by civetweb. Currently, two SSI +Unknown SSI directives are silently ignored by LibHTTP. Currently, two SSI directives are supported, `