Skip to content

Commit

Permalink
Updated mongoose code
Browse files Browse the repository at this point in the history
  • Loading branch information
COM8 committed Oct 14, 2023
1 parent 46ada79 commit 354da2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 3 additions & 7 deletions test/abstractServer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "abstractServer.hpp"
#include "mongoose.h"

namespace cpr {
void AbstractServer::SetUp() {
Expand Down Expand Up @@ -42,11 +43,6 @@ static void EventHandler(mg_connection* conn, int event, void* event_data, void*
case MG_EV_CONNECT:
/** Do nothing. Just for housekeeping. **/
break;

case MG_EV_HTTP_CHUNK: {
/** Do nothing. Just for housekeeping. **/
} break;

case MG_EV_HTTP_MSG: {
AbstractServer* server = static_cast<AbstractServer*>(context);
server->OnRequest(conn, static_cast<mg_http_message*>(event_data));
Expand Down Expand Up @@ -132,11 +128,11 @@ bool AbstractServer::IsConnectionActive(mg_mgr* mgr, mg_connection* conn) {
return false;
}

uint16_t AbstractServer::GetRemotePort(const mg_connection* conn) {
uint16_t AbstractServer::GetRemotePort(const mg_connection* conn) {
return (conn->rem.port >> 8) | (conn->rem.port << 8);
}

uint16_t AbstractServer::GetLocalPort(const mg_connection* conn) {
uint16_t AbstractServer::GetLocalPort(const mg_connection* conn) {
return (conn->loc.port >> 8) | (conn->loc.port << 8);
}

Expand Down
8 changes: 6 additions & 2 deletions test/httpsServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ namespace cpr {
HttpsServer::HttpsServer(fs::path&& baseDirPath, fs::path&& sslCertFileName, fs::path&& sslKeyFileName) : baseDirPath(baseDirPath.make_preferred().string()), sslCertFileName(sslCertFileName.make_preferred().string()), sslKeyFileName(sslKeyFileName.make_preferred().string()) {
// See https://mongoose.ws/tutorials/tls/
memset(static_cast<void*>(&tlsOpts), 0, sizeof(tlsOpts));
tlsOpts.cert = this->sslCertFileName.c_str();
tlsOpts.certkey = this->sslKeyFileName.c_str();
tlsOpts.cert.ptr = this->sslCertFileName.c_str();
tlsOpts.cert.len = this->sslCertFileName.size();
tlsOpts.key.ptr = this->sslKeyFileName.c_str();
tlsOpts.key.len = this->sslKeyFileName.size();
tlsOpts.ca.ptr = nullptr;
tlsOpts.name.ptr = nullptr;
}

std::string HttpsServer::GetBaseUrl() {
Expand Down

0 comments on commit 354da2f

Please sign in to comment.