From c7bd02be853694ef066d341809befc95bba53e4a Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Tue, 22 Oct 2024 14:56:28 -0400 Subject: [PATCH] Changed to CC0 license, added work-in-progress code for HTTP/1 --- LICENSE | 10 +------ source/handy_http_transport/http1/transport.d | 26 +++++++++++++++++++ source/handy_http_transport/interfaces.d | 21 +++++++++++++-- 3 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 source/handy_http_transport/http1/transport.d diff --git a/LICENSE b/LICENSE index 39b0ae1..77d90b5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1 @@ -MIT License - -Copyright (c) 2024 Handy-Http - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Handy-Http by Andrew Lalis is marked with CC0 1.0 Universal. To view a copy of this license, visit https://creativecommons.org/publicdomain/zero/1.0/ \ No newline at end of file diff --git a/source/handy_http_transport/http1/transport.d b/source/handy_http_transport/http1/transport.d new file mode 100644 index 0000000..a0c2949 --- /dev/null +++ b/source/handy_http_transport/http1/transport.d @@ -0,0 +1,26 @@ +module handy_http_transport.http1.transport; + +import std.socket; + +import handy_http_transport.interfaces; +import handy_http_primitives; + +/** + * The HTTP/1.1 transport protocol implementation. + */ +class Http1Transport : HttpTransport { + private Socket serverSocket; + private SocketSet socketSet; + + this(HttpRequestAcceptor requestAcceptor) { + super(requestAcceptor); + this.serverSocket = new TcpSocket(); + } + + void start() { + serverSocket.bind(new InternetAddress("127.0.0.1", 8080)); + while (true) { + uint socketCount = 0; + } + } +} \ No newline at end of file diff --git a/source/handy_http_transport/interfaces.d b/source/handy_http_transport/interfaces.d index 3e03d8c..1995474 100644 --- a/source/handy_http_transport/interfaces.d +++ b/source/handy_http_transport/interfaces.d @@ -1,7 +1,24 @@ module handy_http_transport.interfaces; +import core.thread.osthread; + import handy_http_primitives; -interface HttpTransport { - +abstract class HttpTransport { + protected HttpRequestAcceptor requestAcceptor; + this(HttpRequestAcceptor requestAcceptor) { + this.requestAcceptor = requestAcceptor; + } + + abstract void start(); + + Thread startInThread() { + Thread t = new Thread(&this.start); + t.start(); + return t; + } +} + +interface HttpRequestAcceptor { + void accept(HttpRequest request, HttpResponse response); }