mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
Added OpenSSL support. #5
This commit is contained in:
parent
2c276ed31a
commit
22f124f871
8 changed files with 373 additions and 100 deletions
|
@ -1,16 +1,17 @@
|
|||
|
||||
USE_CLANG = 1
|
||||
|
||||
ifdef USE_CLANG
|
||||
CC = clang++
|
||||
CCFLAGS = -std=c++1y -stdlib=libc++ -g -DGTEST_USE_OWN_TR1_TUPLE
|
||||
else
|
||||
CC = g++-4.9
|
||||
CCFLAGS = -std=c++1y -g
|
||||
endif
|
||||
CFLAGS = -std=c++14 -DGTEST_USE_OWN_TR1_TUPLE -I.. -I.
|
||||
#OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib -lssl -lcrypto
|
||||
|
||||
all : test
|
||||
./test
|
||||
|
||||
test : test.cc ../httplib.h
|
||||
$(CC) -o test $(CCFLAGS) -I.. -I. test.cc gtest/gtest-all.cc gtest/gtest_main.cc
|
||||
$(CC) -o test $(CFLAGS) test.cc gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT)
|
||||
|
||||
pem:
|
||||
openssl genrsa 2048 > key.pem
|
||||
openssl req -new -key key.pem | openssl x509 -days 3650 -req -signkey key.pem > cert.pem
|
||||
|
||||
clean:
|
||||
rm test *.pem
|
||||
|
|
18
test/test.cc
18
test/test.cc
|
@ -4,6 +4,9 @@
|
|||
#include <future>
|
||||
#include <iostream>
|
||||
|
||||
#define SERVER_CERT_FILE "./cert.pem"
|
||||
#define SERVER_PRIVATE_KEY_FILE "./key.pem"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <process.h>
|
||||
#define msleep(n) ::Sleep(n)
|
||||
|
@ -99,8 +102,12 @@ TEST(GetHeaderValueTest, RegularValueInt)
|
|||
|
||||
class ServerTest : public ::testing::Test {
|
||||
protected:
|
||||
ServerTest() : cli_(HOST, PORT), up_(false) {
|
||||
}
|
||||
ServerTest()
|
||||
: cli_(HOST, PORT)
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
, svr_(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE)
|
||||
#endif
|
||||
, up_(false) {}
|
||||
|
||||
virtual void SetUp() {
|
||||
svr_.set_base_dir("./www");
|
||||
|
@ -155,8 +162,13 @@ protected:
|
|||
}
|
||||
|
||||
map<string, string> persons_;
|
||||
Server svr_;
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
SSLClient cli_;
|
||||
SSLServer svr_;
|
||||
#else
|
||||
Client cli_;
|
||||
Server svr_;
|
||||
#endif
|
||||
future<void> f_;
|
||||
bool up_;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue