diff --git a/source/vibe/http/internal/http1/server.d b/source/vibe/http/internal/http1/server.d index 80faf79..55cee71 100644 --- a/source/vibe/http/internal/http1/server.d +++ b/source/vibe/http/internal/http1/server.d @@ -69,7 +69,7 @@ void handleHTTP1Connection(TLSStreamType)(TCPConnection connection, TLSStreamTyp private bool handleRequest(TLSStreamType, Allocator)(StreamProxy http_stream, TCPConnection tcp_connection, HTTPServerContext listen_info, ref HTTPServerSettings settings, ref bool keep_alive, scope Allocator request_allocator) @safe { - import vibe.container.internal.utilallocator : make; + import vibe.container.internal.utilallocator : make, dispose; import vibe.http.internal.utils : formatRFC822DateAlloc; import std.algorithm.searching : canFind, startsWith; import std.conv : parse, to; @@ -104,6 +104,7 @@ private bool handleRequest(TLSStreamType, Allocator)(StreamProxy http_stream, TC // Create the response object ConnectionStreamProxy cproxy = tcp_connection; auto exchange = () @trusted { return request_allocator.make!HTTP1ServerExchange(http_stream, cproxy); } (); + scope (exit) () @trusted { request_allocator.dispose(exchange); } (); auto res = FreeListRef!HTTPServerResponse(exchange, settings, request_allocator/*.Scoped_payload*/); req.tls = res.m_tls = listen_info.tlsContext !is null; if (req.tls) { diff --git a/source/vibe/http/internal/http2/exchange.d b/source/vibe/http/internal/http2/exchange.d index 3d8351f..555a02b 100644 --- a/source/vibe/http/internal/http2/exchange.d +++ b/source/vibe/http/internal/http2/exchange.d @@ -165,6 +165,7 @@ bool handleHTTP2Request(UStream)(ref HTTP2ConnectionStream!UStream stream, // initialize request auto req = () @trusted { return alloc.make!HTTPServerRequest(reqtime, listen_info.bindPort); } (); + scope (exit) () @trusted { alloc.dispose(req); } (); // store the IP address req.clientAddress = tcp_connection.remoteAddress; @@ -251,8 +252,9 @@ bool handleHTTP2Request(UStream)(ref HTTP2ConnectionStream!UStream stream, auto exchange = () @trusted { return alloc.make!(HTTP2ServerExchange!UStream)(stream, tcpc, h2context, headers, table, alloc); } (); - scope (exit) () @trusted { destroy(exchange); } (); + scope (exit) () @trusted { alloc.dispose(exchange); } (); auto res = () @trusted { return alloc.make!HTTPServerResponse(exchange, settings, alloc); } (); + scope (exit) () @trusted { alloc.dispose(res); } (); res.httpVersion = HTTPVersion.HTTP_2; // setup compressed output