Skip to content

Commit c545908

Browse files
committed
remove dead code
1 parent e56e53d commit c545908

17 files changed

+15
-561
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ Once you have Mojo set up locally,
8888
struct Printer(HTTPService):
8989
fn func(self, req: HTTPRequest) raises -> HTTPResponse:
9090
let body = req.body_raw
91-
9291
print(String(body))
9392
9493
return OK(body)

lightbug_http/args.mojo

-3
This file was deleted.

lightbug_http/body.mojo

-13
This file was deleted.

lightbug_http/error.mojo

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from lightbug_http.http import HTTPResponse
22
from lightbug_http.header import ResponseHeader
33

44

5+
# TODO: Custom error handlers provided by the user
56
@value
67
struct ErrorHandler:
78
fn Error(self) -> HTTPResponse:

lightbug_http/header.mojo

-35
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from lightbug_http.strings import (
2-
TwoLines,
32
next_line,
43
strHttp11,
54
strHttp10,
@@ -19,33 +18,21 @@ struct RequestHeader:
1918
var disable_normalization: Bool
2019
var no_http_1_1: Bool
2120
var __connection_close: Bool
22-
var no_default_content_type: Bool
23-
24-
var cookies_collected: Bool
25-
2621
var content_length: Int
2722
var content_length_bytes: Bytes
28-
2923
var __method: Bytes
3024
var __request_uri: Bytes
3125
var proto: Bytes
3226
var __host: Bytes
3327
var __content_type: Bytes
3428
var __user_agent: Bytes
35-
36-
# TODO: var cookies
37-
38-
# immutable copy of original headers
3929
var raw_headers: Bytes
40-
4130
var __trailer: Bytes
4231

4332
fn __init__(inout self) -> None:
4433
self.disable_normalization = False
4534
self.no_http_1_1 = False
4635
self.__connection_close = False
47-
self.no_default_content_type = False
48-
self.cookies_collected = False
4936
self.content_length = 0
5037
self.content_length_bytes = Bytes()
5138
self.__method = Bytes()
@@ -61,8 +48,6 @@ struct RequestHeader:
6148
self.disable_normalization = False
6249
self.no_http_1_1 = False
6350
self.__connection_close = False
64-
self.no_default_content_type = False
65-
self.cookies_collected = False
6651
self.content_length = 0
6752
self.content_length_bytes = Bytes()
6853
self.__method = Bytes()
@@ -79,8 +64,6 @@ struct RequestHeader:
7964
disable_normalization: Bool,
8065
no_http_1_1: Bool,
8166
connection_close: Bool,
82-
no_default_content_type: Bool,
83-
cookies_collected: Bool,
8467
content_length: Int,
8568
content_length_bytes: Bytes,
8669
method: Bytes,
@@ -95,8 +78,6 @@ struct RequestHeader:
9578
self.disable_normalization = disable_normalization
9679
self.no_http_1_1 = no_http_1_1
9780
self.__connection_close = connection_close
98-
self.no_default_content_type = no_default_content_type
99-
self.cookies_collected = cookies_collected
10081
self.content_length = content_length
10182
self.content_length_bytes = content_length_bytes
10283
self.__method = method
@@ -300,20 +281,14 @@ struct ResponseHeader:
300281
var disable_normalization: Bool
301282
var no_http_1_1: Bool
302283
var __connection_close: Bool
303-
var no_default_content_type: Bool
304-
var no_default_date: Bool
305-
306284
var __status_code: Int
307285
var __status_message: Bytes
308286
var __protocol: Bytes
309287
var content_length: Int
310288
var content_length_bytes: Bytes
311-
312289
var __content_type: Bytes
313290
var __content_encoding: Bytes
314291
var __server: Bytes
315-
316-
# TODO: var cookies
317292
var __trailer: Bytes
318293

319294
fn __init__(
@@ -322,8 +297,6 @@ struct ResponseHeader:
322297
self.disable_normalization = False
323298
self.no_http_1_1 = False
324299
self.__connection_close = False
325-
self.no_default_content_type = False
326-
self.no_default_date = False
327300
self.__status_code = 200
328301
self.__status_message = Bytes()
329302
self.__protocol = Bytes()
@@ -343,8 +316,6 @@ struct ResponseHeader:
343316
self.disable_normalization = False
344317
self.no_http_1_1 = False
345318
self.__connection_close = False
346-
self.no_default_content_type = False
347-
self.no_default_date = False
348319
self.__status_code = status_code
349320
self.__status_message = status_message
350321
self.__protocol = Bytes()
@@ -365,8 +336,6 @@ struct ResponseHeader:
365336
self.disable_normalization = False
366337
self.no_http_1_1 = False
367338
self.__connection_close = connection_close
368-
self.no_default_content_type = False
369-
self.no_default_date = False
370339
self.__status_code = status_code
371340
self.__status_message = status_message
372341
self.__protocol = Bytes()
@@ -382,8 +351,6 @@ struct ResponseHeader:
382351
disable_normalization: Bool,
383352
no_http_1_1: Bool,
384353
connection_close: Bool,
385-
no_default_content_type: Bool,
386-
no_default_date: Bool,
387354
status_code: Int,
388355
status_message: Bytes,
389356
protocol: Bytes,
@@ -397,8 +364,6 @@ struct ResponseHeader:
397364
self.disable_normalization = disable_normalization
398365
self.no_http_1_1 = no_http_1_1
399366
self.__connection_close = connection_close
400-
self.no_default_content_type = no_default_content_type
401-
self.no_default_date = no_default_date
402367
self.__status_code = status_code
403368
self.__status_message = status_message
404369
self.__protocol = protocol

lightbug_http/http.mojo

+2-44
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
from time import now
22
from external.morrow import Morrow
3-
from lightbug_http.header import RequestHeader, ResponseHeader
43
from lightbug_http.uri import URI
5-
from lightbug_http.args import Args
6-
from lightbug_http.stream import StreamReader
7-
from lightbug_http.body import Body, RequestBodyWriter, ResponseBodyWriter
4+
from lightbug_http.header import RequestHeader, ResponseHeader
85
from lightbug_http.io.bytes import Bytes
96
from lightbug_http.io.sync import Duration
107
from lightbug_http.net import Addr, TCPAddr
11-
from lightbug_http.strings import TwoLines, next_line, strHttp11, strHttp10, strHttp
8+
from lightbug_http.strings import strHttp11, strHttp
129

1310

1411
trait Request:
@@ -19,7 +16,6 @@ trait Request:
1916
inout self,
2017
header: RequestHeader,
2118
uri: URI,
22-
post_args: Args,
2319
body: Bytes,
2420
parsed_uri: Bool,
2521
server_is_tls: Bool,
@@ -74,32 +70,16 @@ trait Response:
7470
struct HTTPRequest(Request):
7571
var header: RequestHeader
7672
var __uri: URI
77-
78-
var post_args: Args
79-
80-
var body_stream: StreamReader
81-
var w: RequestBodyWriter
82-
var body: Body
8373
var body_raw: Bytes
8474

85-
# TODO: var multipart_form
86-
# TODO: var multipart_form_boundary
87-
8875
var parsed_uri: Bool
89-
9076
var server_is_tls: Bool
91-
9277
var timeout: Duration
93-
9478
var disable_redirect_path_normalization: Bool
9579

9680
fn __init__(inout self, uri: URI):
9781
self.header = RequestHeader()
9882
self.__uri = uri
99-
self.post_args = Args()
100-
self.body_stream = StreamReader()
101-
self.w = RequestBodyWriter()
102-
self.body = Body()
10383
self.body_raw = Bytes()
10484
self.parsed_uri = False
10585
self.server_is_tls = False
@@ -109,10 +89,6 @@ struct HTTPRequest(Request):
10989
fn __init__(inout self, uri: URI, buf: Bytes, headers: RequestHeader):
11090
self.header = headers
11191
self.__uri = uri
112-
self.post_args = Args()
113-
self.body_stream = StreamReader()
114-
self.w = RequestBodyWriter()
115-
self.body = Body()
11692
self.body_raw = buf
11793
self.parsed_uri = False
11894
self.server_is_tls = False
@@ -123,7 +99,6 @@ struct HTTPRequest(Request):
12399
inout self,
124100
header: RequestHeader,
125101
uri: URI,
126-
post_args: Args,
127102
body: Bytes,
128103
parsed_uri: Bool,
129104
server_is_tls: Bool,
@@ -132,10 +107,6 @@ struct HTTPRequest(Request):
132107
):
133108
self.header = header
134109
self.__uri = uri
135-
self.post_args = post_args
136-
self.body_stream = StreamReader()
137-
self.w = RequestBodyWriter()
138-
self.body = Body()
139110
self.body_raw = body
140111
self.parsed_uri = parsed_uri
141112
self.server_is_tls = server_is_tls
@@ -181,17 +152,10 @@ struct HTTPRequest(Request):
181152
@value
182153
struct HTTPResponse(Response):
183154
var header: ResponseHeader
184-
185155
var stream_immediate_header_flush: Bool
186156
var stream_body: Bool
187-
188-
var body_stream: StreamReader
189-
var w: ResponseBodyWriter
190-
var body: Body
191157
var body_raw: Bytes
192-
193158
var skip_reading_writing_body: Bool
194-
195159
var raddr: TCPAddr
196160
var laddr: TCPAddr
197161

@@ -204,9 +168,6 @@ struct HTTPResponse(Response):
204168
)
205169
self.stream_immediate_header_flush = False
206170
self.stream_body = False
207-
self.body_stream = StreamReader()
208-
self.w = ResponseBodyWriter()
209-
self.body = Body()
210171
self.body_raw = body_bytes
211172
self.skip_reading_writing_body = False
212173
self.raddr = TCPAddr()
@@ -216,9 +177,6 @@ struct HTTPResponse(Response):
216177
self.header = header
217178
self.stream_immediate_header_flush = False
218179
self.stream_body = False
219-
self.body_stream = StreamReader()
220-
self.w = ResponseBodyWriter()
221-
self.body = Body()
222180
self.body_raw = body_bytes
223181
self.skip_reading_writing_body = False
224182
self.raddr = TCPAddr()

lightbug_http/io/unix_utils.mojo

-6
This file was deleted.

lightbug_http/net.mojo

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from lightbug_http.strings import NetworkType
2-
from lightbug_http.io.bytes import Bytes, UnsafeString
2+
from lightbug_http.io.bytes import Bytes
33
from lightbug_http.io.sync import Duration
44

55
alias default_buffer_size = 4096

lightbug_http/python/client.mojo

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
from lightbug_http.client import Client
2-
from lightbug_http.http import HTTPRequest, HTTPResponse, encode
3-
from lightbug_http.uri import URI
4-
from lightbug_http.header import ResponseHeader, RequestHeader
5-
from lightbug_http.python.net import PythonTCPListener, PythonListenConfig, PythonNet
2+
from lightbug_http.http import HTTPRequest, HTTPResponse
63
from lightbug_http.python import Modules
7-
from lightbug_http.service import HTTPService
8-
from lightbug_http.io.sync import Duration
94
from lightbug_http.io.bytes import Bytes, UnsafeString
10-
from lightbug_http.error import ErrorHandler
11-
from lightbug_http.strings import next_line, NetworkType, strHttp, CharSet
5+
from lightbug_http.strings import CharSet
126

137

148
struct PythonClient(Client):

lightbug_http/python/net.mojo

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ from lightbug_http.net import (
99
resolve_internet_addr,
1010
default_buffer_size,
1111
)
12-
from lightbug_http.http import Request, Response
13-
from lightbug_http.service import HTTPService
1412
from lightbug_http.net import Connection, default_tcp_keep_alive
15-
from lightbug_http.strings import NetworkType, CharSet
13+
from lightbug_http.strings import CharSet
1614

1715

1816
@value

0 commit comments

Comments
 (0)