Skip to content

Commit

Permalink
Merge pull request #27 from JadeMatrix/v0.8.5
Browse files Browse the repository at this point in the history
v0.8.5
  • Loading branch information
JadeMatrix authored Jun 4, 2018
2 parents c3d2e05 + 4d42008 commit 6a4c830
Show file tree
Hide file tree
Showing 19 changed files with 304 additions and 218 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ SET( CMAKE_CXX_STANDARD_REQUIRED ON )

PROJECT(
"SHOW Tests & Examples"
CXX
VERSION 0.8.5
LANGUAGES CXX
)

FIND_LIBRARY( UNITTEST_LIBRARY UnitTest++ )
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ SHOW is an idiomatic library for standalone webserver applications written for m

SHOW assumes a modern approach to application hosting, and is intended to be run behind a full reverse proxy such as [NGINX](https://nginx.org/). As such, SHOW will not support HTTP/2 or TLS (HTTPS); instead, you should write your applications to serve local HTTP/1.0 and HTTP/1.1 requests.

You can find SHOW's documentation, including a tutorial, on [ReadTheDocs.io](http://show-cpp.readthedocs.io/). SHOW uses the [`zlib` license](LICENSE). A C++11 compiler and a POSIX operating system are required.
You can find SHOW's documentation, including a tutorial, on [ReadTheDocs.io](http://show-cpp.readthedocs.io/). SHOW is released under the [`zlib` license](LICENSE). A C++11 compiler and a POSIX operating system (or POSIX compatibility layer) are required.
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# The short X.Y version.
version = u'0.8'
# The full version, including alpha/beta/rc tags.
release = u'0.8.4'
release = u'0.8.5'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SHOW is designed to be an idiomatic library for standalone webserver application

Both HTTP/1.0 and HTTP/1.1 are supported. SHOW assumes a modern approach to application hosting, and is intended to be run behind a full reverse proxy such as `NGINX <https://nginx.org/>`_. As such, SHOW will not support HTTP/2 or TLS (HTTPS). Instead, you should write your applications to serve local HTTP/1.0 and HTTP/1.1 requests.

SHOW uses the `zlib license <https://github.com/JadeMatrix/SHOW/blob/master/LICENSE>`_. C++11 support and a POSIX operating system are required.
SHOW is released under the `zlib license <https://github.com/JadeMatrix/SHOW/blob/master/LICENSE>`_. C++11 support and a POSIX operating system (or POSIX compatibility layer) are required.

.. toctree::
:maxdepth: 2
Expand Down
2 changes: 1 addition & 1 deletion examples/echo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void handle_POST_request( show::request& request )
// otherwise use the default MIME type recommended in the HTTP
// specification, RFC 2616 §7.2.1:
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1
auto content_type_header{ request.headers().find( "Content-Type" ) };
auto content_type_header = request.headers().find( "Content-Type" );
if(
content_type_header != request.headers().end()
&& content_type_header -> second.size() == 1
Expand Down
20 changes: 18 additions & 2 deletions examples/fileserve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ void handle_GET_request(
// Keep a seperate string `full_path_string` to represent the path on
// the server's system; this path should never be send back to the
// client -- use `path_string` instead.
auto full_path_string{ rel_dir + path_string };
auto full_path_string = rel_dir + path_string;

if( is_directory( full_path_string ) )
{
auto children{ scan_directory( full_path_string ) };
auto children = scan_directory( full_path_string );

// Send back a directory listing as an HTML5 page
std::stringstream content;
Expand Down Expand Up @@ -266,6 +266,17 @@ void handle_GET_request(
}
else
{
bool download{ true };
auto found_download = request.query_args().find( "download" );
if( found_download != request.query_args().end() )
{
for( auto& val : found_download -> second )
if( val == "false" )
download = false;
}
else
download = false;

// Open the file in binary input mode, with the cursor starting at
// the end so we can get the file size
std::ifstream file{
Expand All @@ -291,6 +302,11 @@ void handle_GET_request(
{ "Content-Type", { guess_mime_type( path_string ) } },
{ "Content-Length", {
std::to_string( remaining )
} },
{ "Content-Disposition", {
std::string{ download ? "attachment" : "inline" }
+ "; filename*=UTF-8''"
+ show::url_encode( request.path().back(), false )
} }
}
};
Expand Down
4 changes: 2 additions & 2 deletions examples/http_1_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void handle_connection( show::connection& connection )
if( !request.unknown_content_length() )
request.flush();

auto is_1p1{ request.protocol() == show::HTTP_1_1 };
auto is_1p1 = request.protocol() == show::HTTP_1_1;

std::string message{
"HTTP/"
Expand Down Expand Up @@ -71,7 +71,7 @@ void handle_connection( show::connection& connection )
// HTTP/1.0 "supports" persistent connections with the "Connection"
// header; this example defers to this header's value (if it exists)
// before checking the protocol version.
auto connection_header{ request.headers().find( "Connection" ) };
auto connection_header = request.headers().find( "Connection" );
if(
connection_header != request.headers().end()
&& connection_header -> second.size() == 1
Expand Down
14 changes: 5 additions & 9 deletions examples/multiple_clients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <iostream> // std::cout, std::cerr
#include <list> // std::list
#include <memory> // std::unique_ptr
#include <thread> // std::thread


Expand All @@ -17,13 +16,13 @@ const show::headers_type::value_type server_header{
};


void handle_connection( std::unique_ptr< show::connection > connection )
void handle_connection( show::connection&& connection )
{
try
{
connection -> timeout( 2 );
connection.timeout( 2 );

show::request request{ *connection };
show::request request{ connection };

// See the HTTP/1.1 example for an explanation
if( !request.unknown_content_length() )
Expand All @@ -49,7 +48,7 @@ void handle_connection( std::unique_ptr< show::connection > connection )
{
std::cout
<< "client "
<< connection -> client_address()
<< connection.client_address()
<< " disconnected or timed out, closing connection"
<< std::endl
;
Expand Down Expand Up @@ -91,10 +90,7 @@ int main( int argc, char* argv[] )
{
std::thread worker{
handle_connection,
// In C++14 and later std::make_unique<>() should be preferred
std::unique_ptr< show::connection >{
new show::connection{ test_server.serve() }
}
test_server.serve()
};
worker.detach();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/streaming_echo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void handle_POST_request( show::request& request )
// otherwise use the default MIME type recommended in the HTTP
// specification, RFC 2616 §7.2.1:
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.2.1
auto content_type_header{ request.headers().find( "Content-Type" ) };
auto content_type_header = request.headers().find( "Content-Type" );
if(
content_type_header != request.headers().end()
&& content_type_header -> second.size() == 1
Expand Down
Loading

0 comments on commit 6a4c830

Please sign in to comment.