Skip to content

Commit 0d10cbc

Browse files
committed
new http server architecture
yup that smells like v3. I hate my adhd!
1 parent f6af01f commit 0d10cbc

42 files changed

Lines changed: 2512 additions & 65 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ lambda_sfi.hpp
2727
*.gz
2828
*.tgz
2929
*.so
30+
31+
# artifacts
32+
**/.artifacts

core/http/status.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static const std::map <int, std::string> statusCodeTable = {
2020
{ 206, "Partial Content" },
2121
{ 207, "Multi-Status" },
2222
{ 226, "IM Used" },
23+
2324
{ 300, "Multiple Choices" },
2425
{ 301, "Moved Permanently" },
2526
{ 302, "Found" },
@@ -28,6 +29,7 @@ static const std::map <int, std::string> statusCodeTable = {
2829
{ 305, "Use Proxy" },
2930
{ 307, "Temporary Redirect" },
3031
{ 308, "Permanent Redirect" },
32+
3133
{ 400, "Bad Request" },
3234
{ 401, "Unauthorized" },
3335
{ 402, "Payment Required" },
@@ -55,6 +57,7 @@ static const std::map <int, std::string> statusCodeTable = {
5557
{ 429, "Too Many Requests" },
5658
{ 431, "Request Header Fields Too Large" },
5759
{ 451, "Unavailable For Legal Reasons" },
60+
5861
{ 500, "Internal Server Error" },
5962
{ 501, "Not Implemented" },
6063
{ 502, "Bad Gateway" },

core/http/transport.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ namespace Lambda::HTTP::Transport {
6666

6767
virtual const std::string& contextID() const noexcept = 0;
6868

69-
virtual Network::TCP::Connection& tcpconn() const noexcept = 0;
70-
virtual const Network::ConnectionInfo& conninfo() const noexcept = 0;
69+
virtual Net::TCP::Connection& tcpconn() const noexcept = 0;
70+
virtual const Net::ConnectionInfo& conninfo() const noexcept = 0;
7171
virtual const TransportOptions& options() const noexcept = 0;
7272
virtual const ContentEncodings& getEnconding() const noexcept = 0;
7373
virtual bool isConnected() const noexcept = 0;

core/http/transport_impl.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Lambda::HTTP::Transport {
1919

2020
class TransportContextV1 : public TransportContext {
2121
private:
22-
Network::TCP::Connection& m_conn;
22+
Net::TCP::Connection& m_conn;
2323
const TransportOptions& m_topts;
2424

2525
const Crypto::ShortID m_id;
@@ -30,12 +30,12 @@ namespace Lambda::HTTP::Transport {
3030
IncomingRequest* m_next = nullptr;
3131

3232
public:
33-
TransportContextV1(Network::TCP::Connection& connInit, const TransportOptions& optsInit);
33+
TransportContextV1(Net::TCP::Connection& connInit, const TransportOptions& optsInit);
3434

3535
const std::string& contextID() const noexcept;
3636

37-
Network::TCP::Connection& tcpconn() const noexcept;
38-
const Network::ConnectionInfo& conninfo() const noexcept;
37+
Net::TCP::Connection& tcpconn() const noexcept;
38+
const Net::ConnectionInfo& conninfo() const noexcept;
3939
const TransportOptions& options() const noexcept;
4040
const ContentEncodings& getEnconding() const noexcept;
4141
bool isConnected() const noexcept;

core/http/transport_v1.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
using namespace Lambda;
1515
using namespace Lambda::HTTP;
1616
using namespace Lambda::HTTP::Transport;
17-
using namespace Lambda::Network;
17+
using namespace Lambda::Net;
1818

1919
static const std::map<ContentEncodings, std::string> contentEncodingMap = {
2020
{ ContentEncodings::Brotli, "br" },
@@ -27,7 +27,7 @@ static const std::initializer_list<std::string> compressibleTypes = {
2727
};
2828

2929
TransportContextV1::TransportContextV1(
30-
Network::TCP::Connection& connInit,
30+
Net::TCP::Connection& connInit,
3131
const TransportOptions& optsInit
3232
) : m_conn(connInit), m_topts(optsInit) {}
3333

@@ -295,7 +295,7 @@ void TransportContextV1::respond(const ResponseContext& responsectx) {
295295
responseHeaders.set("content-length", std::to_string(bodyBufferSize));
296296
}
297297

298-
responseHeaders.set("date", Date().toUTCString());
298+
responseHeaders.set("date", Date().to_utc_string());
299299
responseHeaders.set("server", "maddsua/lambda");
300300
responseHeaders.set("x-request-id", this->m_id.toString() + '-' + responsectx.id.toString());
301301

@@ -355,15 +355,15 @@ const std::string& TransportContextV1::contextID() const noexcept {
355355
return this->m_id.toString();
356356
}
357357

358-
const Network::ConnectionInfo& TransportContextV1::conninfo() const noexcept {
358+
const Net::ConnectionInfo& TransportContextV1::conninfo() const noexcept {
359359
return this->m_conn.info();
360360
}
361361

362362
const TransportOptions& TransportContextV1::options() const noexcept {
363363
return this->m_topts;
364364
}
365365

366-
Network::TCP::Connection& TransportContextV1::tcpconn() const noexcept {
366+
Net::TCP::Connection& TransportContextV1::tcpconn() const noexcept {
367367
return this->m_conn;
368368
}
369369

@@ -398,7 +398,7 @@ void TransportContextV1::writeRaw(const std::vector<uint8_t>& data) {
398398
}
399399

400400
std::vector<uint8_t> TransportContextV1::readRaw() {
401-
return this->readRaw(Network::TCP::Connection::DefaultChunkSize);
401+
return this->readRaw(Net::TCP::Connection::DefaultChunkSize);
402402
}
403403

404404
std::vector<uint8_t> TransportContextV1::readRaw(size_t expectedSize) {

core/network/error.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "./sysnetw.hpp"
33

44
using namespace Lambda;
5-
using namespace Lambda::Network;
5+
using namespace Lambda::Net;
66

77
NetworkError::NetworkError(const std::string& message) : Error(message) {
88
this->m_code = GetOSErrorCode();

core/network/network.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <cstdint>
77
#include <string>
88

9-
namespace Lambda::Network {
9+
namespace Lambda::Net {
1010

1111
enum struct ConnectionTransport {
1212
TCP, UDP

core/network/tcp/connection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
#include <set>
55

6-
using namespace Lambda::Network;
7-
using namespace Lambda::Network::TCP;
6+
using namespace Lambda::Net;
7+
using namespace Lambda::Net::TCP;
88

99
static const std::set<int> blockingEndedCodes = {
1010
#ifdef _WIN32

core/network/tcp/connection.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <string>
88
#include <mutex>
99

10-
namespace Lambda::Network::TCP {
10+
namespace Lambda::Net::TCP {
1111

1212
struct ConnectionFlags {
1313
/**

core/network/tcp/listener.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "./connection.hpp"
33
#include "../sysnetw.hpp"
44

5-
using namespace Lambda::Network;
6-
using namespace Lambda::Network::TCP;
5+
using namespace Lambda::Net;
6+
using namespace Lambda::Net::TCP;
77

88
ListenSocket::ListenSocket(const ListenConfig& init) : config(init) {
99

0 commit comments

Comments
 (0)