mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 04:34:40 +03:00
see #2: update exercises and maintains of content
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# Makefile
|
||||
# web_server
|
||||
#
|
||||
# created by changkun at labex.io
|
||||
# created by changkun at changkun.de/modern-cpp
|
||||
#
|
||||
|
||||
CXX = g++
|
||||
@@ -15,15 +15,16 @@ SOURCE_HTTPS = main.https.cpp
|
||||
OBJECTS_HTTP = main.http.o
|
||||
OBJECTS_HTTPS = main.https.o
|
||||
|
||||
LDFLAGS_COMMON = -std=c++11 -O3 -pthread -lboost_system
|
||||
LDFLAGS_COMMON = -std=c++2a -O3 -pthread -lboost_system
|
||||
LDFLAGS_HTTP =
|
||||
LDFLAGS_HTTPS = -lssl -lcrypto
|
||||
|
||||
LPATH_COMMON = -I/usr/include/boost
|
||||
LPATH_HTTP =
|
||||
LPATH_HTTPS = -I/usr/include/openssl
|
||||
LPATH_HTTPS = -I/usr/local/opt/openssl/include
|
||||
|
||||
LLIB_COMMON = -L/usr/lib
|
||||
LLIB_HTTPS = -L/usr/local/opt/openssl/lib
|
||||
|
||||
all:
|
||||
make http
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace std;
|
||||
using namespace LabexWeb;
|
||||
using namespace Web;
|
||||
|
||||
template<typename SERVER_TYPE>
|
||||
void start_server(SERVER_TYPE &server) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "server.http.hpp"
|
||||
#include "handler.hpp"
|
||||
|
||||
using namespace LabexWeb;
|
||||
using namespace Web;
|
||||
|
||||
int main() {
|
||||
// HTTP server runs in port 12345 HTTP, enable 4 threads
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <iostream>
|
||||
#include "server.https.hpp"
|
||||
#include "handler.hpp"
|
||||
using namespace LabexWeb;
|
||||
using namespace Web;
|
||||
|
||||
int main() {
|
||||
// HTTPS server runs in port 12345, enable 4 threads
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <unordered_map>
|
||||
#include <thread>
|
||||
|
||||
namespace LabexWeb {
|
||||
namespace Web {
|
||||
struct Request {
|
||||
// request method, POST, GET; path; HTTP version
|
||||
std::string method, path, http_version;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "server.base.hpp"
|
||||
|
||||
namespace LabexWeb {
|
||||
namespace Web {
|
||||
typedef boost::asio::ip::tcp::socket HTTP;
|
||||
template<>
|
||||
class Server<HTTP> : public ServerBase<HTTP> {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "server.http.hpp"
|
||||
#include <boost/asio/ssl.hpp>
|
||||
|
||||
namespace LabexWeb {
|
||||
namespace Web {
|
||||
|
||||
// define HTTPS type
|
||||
typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> HTTPS;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>LabEx Web Server Test</title>
|
||||
<title>Web Server Test</title>
|
||||
</head>
|
||||
<body>
|
||||
Hello world in index.html.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>LabEx Web Server Test</title>
|
||||
<title>Web Server Test</title>
|
||||
</head>
|
||||
<body>
|
||||
Hello world in test.html.
|
||||
|
||||
Reference in New Issue
Block a user