lowloop 0.8.19 → 0.8.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfa90ecaa4270aadf325053b4e2e50c20a6c93339ec59e58a6739fd7752c9486
4
- data.tar.gz: 8254d17ed1aca9301aa8216bd61897f0bf634297284002f820f1dbcbf367c0cb
3
+ metadata.gz: 18b2f0ae67dc62083d5d2f241ff7ef4ce1d9b559e43c7e2ea501dc9374ce2348
4
+ data.tar.gz: 4541c743b8ceb475f5741fbea328afb87fb4e517700e8b6364974f2c6c346d3a
5
5
  SHA512:
6
- metadata.gz: 6eb1fa0d79dc9a290f16035f9c13466195c473188084de9c8f15f12d9fa63fb4baec8447d175c52305c561294b17fdf54dee92f1d1cd4df5451e6698ab4f81d8
7
- data.tar.gz: 7665d750b778779fb72ebfce139a8cc30e3e844ab92f009b6f05cf0c8cb5703c8138f84203b6ed75cc33ac282c857b676730e698d986a4ec46f93ef9ee4649d0
6
+ metadata.gz: 2c6c514cebe4cee697089fd971d30fa28e65ddb03f4ba4b2bd719d556d103366c69f777b0a5db3ed74564ac92a2a11bea26c4bdf8e064223463c97c7c297433c
7
+ data.tar.gz: ad5cc40e75412e724eb131be6449dca588da2b4e2e17fdf44e26aea8d1523e0fe4ce826256e173fe84217dc53324c87fcb5882d78b38644046d16d57c2f4e8fe
@@ -45,14 +45,13 @@ module Low
45
45
  def serve_requests(socket:)
46
46
  stream = RequestParser.create_stream(socket:)
47
47
  keep_alive = true
48
- version = nil
49
48
 
50
49
  while keep_alive
51
50
  break unless socket.wait_readable(keep_alive_timeout)
52
51
 
53
52
  socket.timeout = request_timeout
54
53
  begin
55
- request = RequestParser.parse(stream:, host: config.host, port: config.port, version:)
54
+ request = RequestParser.parse(stream:, host: config.host, port: config.port)
56
55
  rescue IO::TimeoutError
57
56
  break
58
57
  ensure
@@ -60,7 +59,6 @@ module Low
60
59
  end
61
60
  break if request.nil?
62
61
 
63
- version ||= request.version
64
62
  unless headers_valid?(request)
65
63
  ResponseBuilder.respond(socket:, response: ResponseFactory.status(code: 400), keep_alive: false)
66
64
  break
@@ -16,13 +16,11 @@ module Low
16
16
  IO::Stream(socket)
17
17
  end
18
18
 
19
- def parse(stream: IO::Stream::Generic, host: String, port: Integer, version: nil) -> { ::Protocol::HTTP::Request | nil }
20
- version ||= Async::HTTP::Protocol::HTTP.default.protocol_for(stream)::VERSION
21
-
19
+ def parse(stream: IO::Stream::Generic, host: String, port: Integer) -> { ::Protocol::HTTP::Request | nil }
22
20
  result = parse_request(stream:)
23
21
  return nil unless result
24
22
 
25
- method, full_path = result
23
+ method, full_path, version = result
26
24
  headers = parse_headers(stream:)
27
25
  body = parse_body(stream:, method:, headers:)
28
26
 
@@ -49,7 +47,7 @@ module Low
49
47
  # :header_3\r\n
50
48
  # \r\n
51
49
  # :body
52
- # The line is read into a new string, so it's stripped in place, and only the method and path are copied out of it.
50
+ # The line is read into a new string so it's stripped in place. A line without a version is an HTTP/1.0 client's.
53
51
  def parse_request(stream: IO::Stream::Generic)
54
52
  request_line = stream.gets || return
55
53
 
@@ -59,7 +57,9 @@ module Low
59
57
  method_end = request_line.index(' ') || request_line.length
60
58
  path_end = request_line.index(' ', method_end + 1) || request_line.length
61
59
 
62
- [request_line[0, method_end], request_line[method_end + 1, path_end - method_end - 1]]
60
+ version = request_line[path_end + 1..]
61
+ version = 'HTTP/1.0' if version.nil? || version.empty?
62
+ [request_line[0, method_end], request_line[method_end + 1, path_end - method_end - 1], version]
63
63
  end
64
64
 
65
65
  def parse_headers(stream: IO::Stream::Generic) -> { ::Protocol::HTTP::Headers }
data/lib/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Low
4
4
  module Loop
5
- VERSION = '0.8.19'
5
+ VERSION = '0.8.20'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lowloop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.19
4
+ version: 0.8.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi