Commit e5948367 authored by jan.koester's avatar jan.koester
Browse files

cleanup

parent abcd98a0
Loading
Loading
Loading
Loading
+3 −15
Changes for test/http.cpp: 3 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ class MyServer : public event {
    }

    void RequestEvent(con &curcon, const int tid, ULONG_PTR args) override {
        std::cerr << "[SERVER] RequestEvent called, RecvData.size()="
                  << curcon.RecvData.size() << std::endl;
        const std::string body = "Hello world\n";
        std::string resp;
        resp += "HTTP/1.1 200 OK\r\n";
@@ -38,7 +36,6 @@ class MyServer : public event {
    }

    void ConnectEvent(con &curcon, const int tid, ULONG_PTR args) override {
        std::cerr << "[SERVER] ConnectEvent called" << std::endl;
    }

    void DisconnectEvent(con &curcon, const int tid, ULONG_PTR args) override {
@@ -62,18 +59,16 @@ int main() {
        srv.runEventloop();
    });

    // Give the server a moment to start listening
    std::this_thread::sleep_for(std::chrono::milliseconds(2000));
    // Give the server time to start the event loop
    std::this_thread::sleep_for(std::chrono::milliseconds(500));

    int result = 1; // default = failure

    try {
        // Connect a client
        tcp client;
        std::cerr << "[DEBUG] Connecting..." << std::endl;
        client.connect("127.0.0.1", 8080);
        std::cerr << "[DEBUG] Connected, fd=" << client.fd() << std::endl;
        client.setTimeout(5000); // 5 second recv/send timeout
        client.setTimeout(5000);

        // Send an HTTP request
        const std::string request =
@@ -85,8 +80,6 @@ int main() {
        buffer sendbuf(request.data(), request.size());
        client.sendData(sendbuf);

        std::cerr << "[DEBUG] Request sent, reading response..." << std::endl;

        // Read the response (with timeout protection)
        std::string response;
        for (;;) {
@@ -94,12 +87,7 @@ int main() {
            size_t n = 0;
            try {
                n = client.recvData(recvbuf);
            } catch (netplus::NetException &ne) {
                std::cerr << "[DEBUG] recvData NetException: " << ne.what()
                          << " type=" << ne.getErrorType() << std::endl;
                break;
            } catch (...) {
                std::cerr << "[DEBUG] recvData unknown exception" << std::endl;
                break;
            }
            if (n == 0) break;