protocol-http1 0.14.4 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of protocol-http1 might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 366333c95d6b5a02d91e6f87c0274fddbe09a8c858bcb3e1cd54dfd5198794a6
4
- data.tar.gz: 99db7c604bcd4a24ff8a96a7eb8aa7096b0f5f517849569780ff3b12aac58026
3
+ metadata.gz: c1c040780ba6a7bae3e921d5a7ff40ba5e656ce66d8a138d2c5382ce42efc317
4
+ data.tar.gz: 551dbe0ecbc187b7b3c0c86507d737eace6b41c4f3b62f0d8a7c6f6d8b0bd0a2
5
5
  SHA512:
6
- metadata.gz: cf0f094e6bf752d20115320c94c1796a56f835f524412ea3c9e51324be1802f517f8585838ee0fb7733529cac33adcc0d557d3ac255ab85fbdbdbf13686f00c1
7
- data.tar.gz: 2c64561ec15d5842047d92311ef7130562ccca0f2302d79e2dcb5c52b85bbe7617235cd22a33cdd10d2b96c0ec2e0faa50c4514b1d48cc674702b7ed3febc5e4
6
+ metadata.gz: a57fcfd40cf929f6e6a096d07513378b6631d5dbdab25431c9c8763fea9e4a1967e77adc8bddc55a2ca8eb5b3232088bbaf9d0af1fed8dad05af20e3702e4ef2
7
+ data.tar.gz: f736986596addfec4908e05d9bf632f79f906cf1508076ec7e5dd5de1e08efee33c9c1edd512aef50c4f483db92b92481ba68929edbefe454db57b445b969f8c
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http/body/readable'
24
7
 
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http/body/readable'
24
7
 
@@ -40,6 +23,7 @@ module Protocol
40
23
  end
41
24
 
42
25
  def close(error = nil)
26
+ # If we are closing the body without fully reading it, the underlying connection is now in an undefined state.
43
27
  if @remaining != 0
44
28
  @stream.close
45
29
  end
@@ -47,14 +31,16 @@ module Protocol
47
31
  super
48
32
  end
49
33
 
34
+ # @raises EOFError if the stream is closed before the expected length is read.
50
35
  def read
51
36
  if @remaining > 0
37
+ # `readpartial` will raise `EOFError` if the stream is closed/finished:
52
38
  if chunk = @stream.readpartial(@remaining)
53
39
  @remaining -= chunk.bytesize
54
40
 
55
41
  return chunk
56
- else
57
- raise EOFError, "Stream closed with #{@remaining} bytes remaining!"
42
+ # else
43
+ # raise EOFError, "Stream closed with #{@remaining} bytes remaining!"
58
44
  end
59
45
  end
60
46
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http/body/readable'
24
7
 
@@ -47,7 +30,8 @@ module Protocol
47
30
  # TODO this is a bit less efficient in order to maintain compatibility with `IO`.
48
31
  def read
49
32
  @stream.readpartial(BLOCK_SIZE)
50
- rescue EOFError
33
+ rescue EOFError, IOError
34
+ # I noticed that in some cases you will get EOFError, and in other cases IOError!?
51
35
  return nil
52
36
  end
53
37
 
@@ -1,24 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
+ # Copyright, 2019, by Brian Morearty.
6
+ # Copyright, 2020, by Bruno Sutic.
22
7
 
23
8
  require 'protocol/http/headers'
24
9
 
@@ -47,7 +32,7 @@ module Protocol
47
32
  UPGRADE = 'upgrade'
48
33
 
49
34
  # HTTP/1.x request line parser:
50
- TOKEN = /[!#$%&'*+-\.^_`|~0-9a-zA-Z]+/.freeze
35
+ TOKEN = /[!#$%&'*+\-\.\^_`|~0-9a-zA-Z]+/.freeze
51
36
  REQUEST_LINE = /\A(#{TOKEN}) ([^\s]+) (HTTP\/\d.\d)\z/.freeze
52
37
 
53
38
  # HTTP/1.x header parser:
@@ -79,12 +64,6 @@ module Protocol
79
64
  # The number of requests processed.
80
65
  attr :count
81
66
 
82
- def upgrade?(headers)
83
- if upgrade = headers[UPGRADE]
84
- return upgrade
85
- end
86
- end
87
-
88
67
  def persistent?(version, method, headers)
89
68
  if method == HTTP::Methods::CONNECT
90
69
  return false
@@ -297,7 +276,7 @@ module Protocol
297
276
  chunk_length += chunk.bytesize
298
277
 
299
278
  if chunk_length > length
300
- raise Error, "Trying to write #{chunk_length} bytes, but content length was #{length} bytes!"
279
+ raise ContentLengthError, "Trying to write #{chunk_length} bytes, but content length was #{length} bytes!"
301
280
  end
302
281
 
303
282
  @stream.write(chunk)
@@ -307,7 +286,7 @@ module Protocol
307
286
  @stream.flush
308
287
 
309
288
  if chunk_length != length
310
- raise Error, "Wrote #{chunk_length} bytes, but content length was #{length} bytes!"
289
+ raise ContentLengthError, "Wrote #{chunk_length} bytes, but content length was #{length} bytes!"
311
290
  end
312
291
  end
313
292
 
@@ -416,13 +395,19 @@ module Protocol
416
395
  read_remainder_body
417
396
  end
418
397
 
419
- def read_upgrade_body(protocol)
420
- read_remainder_body
421
- end
422
-
423
398
  HEAD = "HEAD"
424
399
  CONNECT = "CONNECT"
425
400
 
401
+ def extract_content_length(headers)
402
+ if content_length = headers.delete(CONTENT_LENGTH)
403
+ if length = Integer(content_length, exception: false) and length >= 0
404
+ yield length
405
+ else
406
+ raise BadRequest, "Invalid content length: #{content_length}"
407
+ end
408
+ end
409
+ end
410
+
426
411
  def read_response_body(method, status, headers)
427
412
  # RFC 7230 3.3.3
428
413
  # 1. Any response to a HEAD request and any response with a 1xx
@@ -431,19 +416,16 @@ module Protocol
431
416
  # header fields, regardless of the header fields present in the
432
417
  # message, and thus cannot contain a message body.
433
418
  if method == HTTP::Methods::HEAD
434
- if content_length = headers.delete(CONTENT_LENGTH)
435
- length = Integer(content_length)
436
-
419
+ extract_content_length(headers) do |length|
437
420
  if length > 0
438
421
  return read_head_body(length)
439
- elsif length == 0
440
- return nil
441
422
  else
442
- raise BadRequest, "Invalid content length: #{content_length}"
423
+ return nil
443
424
  end
444
- else
445
- return nil
446
425
  end
426
+
427
+ # There is no body for a HEAD request if there is no content length:
428
+ return nil
447
429
  end
448
430
 
449
431
  if (status >= 100 and status < 200) or status == 204 or status == 304
@@ -515,14 +497,11 @@ module Protocol
515
497
  # the recipient times out before the indicated number of octets are
516
498
  # received, the recipient MUST consider the message to be
517
499
  # incomplete and close the connection.
518
- if content_length = headers.delete(CONTENT_LENGTH)
519
- length = Integer(content_length)
500
+ extract_content_length(headers) do |length|
520
501
  if length > 0
521
502
  return read_fixed_body(length)
522
- elsif length == 0
523
- return nil
524
503
  else
525
- raise BadRequest, "Invalid content length: #{content_length}"
504
+ return nil
526
505
  end
527
506
  end
528
507
 
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2023, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http/error'
24
7
 
@@ -30,6 +13,10 @@ module Protocol
30
13
  class InvalidRequest < Error
31
14
  end
32
15
 
16
+ # The specified content length and the given content's length do not match.
17
+ class ContentLengthError < Error
18
+ end
19
+
33
20
  # The request was parsed correctly, but was invalid for some other reason.
34
21
  class BadRequest < Error
35
22
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
22
5
 
23
6
  require 'protocol/http/error'
24
7
 
@@ -1,27 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
22
5
 
23
6
  module Protocol
24
7
  module HTTP1
25
- VERSION = "0.14.4"
8
+ VERSION = "0.15.0"
26
9
  end
27
10
  end
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # Released under the MIT License.
4
+ # Copyright, 2019-2022, by Samuel Williams.
22
5
 
23
6
  require_relative 'http1/version'
24
7
  require_relative 'http1/connection'
data/license.md ADDED
@@ -0,0 +1,24 @@
1
+ # MIT License
2
+
3
+ Copyright, 2019-2023, by Samuel Williams.
4
+ Copyright, 2019, by Brian Morearty.
5
+ Copyright, 2020, by Olle Jonsson.
6
+ Copyright, 2020, by Bruno Sutic.
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,92 @@
1
+ # Protocol::HTTP1
2
+
3
+ Provides a low-level implementation of the HTTP/1 protocol.
4
+
5
+ [![Development Status](https://github.com/socketry/protocol-http1/workflows/Test/badge.svg)](https://github.com/socketry/protocol-http1/actions?workflow=Test)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ``` ruby
12
+ gem 'protocol-http1'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install protocol-http1
22
+
23
+ ## Usage
24
+
25
+ Here is a basic HTTP/1.1 client:
26
+
27
+ ``` ruby
28
+ require 'async'
29
+ require 'async/io/stream'
30
+ require 'async/http/endpoint'
31
+ require 'protocol/http1/connection'
32
+
33
+ Async do
34
+ endpoint = Async::HTTP::Endpoint.parse("https://www.google.com/search?q=kittens", alpn_protocols: ["http/1.1"])
35
+
36
+ peer = endpoint.connect
37
+
38
+ puts "Connected to #{peer} #{peer.remote_address.inspect}"
39
+
40
+ # IO Buffering...
41
+ stream = Async::IO::Stream.new(peer)
42
+ client = Protocol::HTTP1::Connection.new(stream)
43
+
44
+ def client.read_line
45
+ @stream.read_until(Protocol::HTTP1::Connection::CRLF) or raise EOFError
46
+ end
47
+
48
+ puts "Writing request..."
49
+ client.write_request("www.google.com", "GET", "/search?q=kittens", "HTTP/1.1", [["Accept", "*/*"]])
50
+ client.write_body(nil)
51
+
52
+ puts "Reading response..."
53
+ response = client.read_response("GET")
54
+
55
+ puts "Got response: #{response.inspect}"
56
+
57
+ puts "Closing client..."
58
+ client.close
59
+ end
60
+ ```
61
+
62
+ ## Contributing
63
+
64
+ 1. Fork it
65
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
66
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
67
+ 4. Push to the branch (`git push origin my-new-feature`)
68
+ 5. Create new Pull Request
69
+
70
+ ## License
71
+
72
+ Released under the MIT license.
73
+
74
+ Copyright, 2019, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
75
+
76
+ Permission is hereby granted, free of charge, to any person obtaining a copy
77
+ of this software and associated documentation files (the "Software"), to deal
78
+ in the Software without restriction, including without limitation the rights
79
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
80
+ copies of the Software, and to permit persons to whom the Software is
81
+ furnished to do so, subject to the following conditions:
82
+
83
+ The above copyright notice and this permission notice shall be included in
84
+ all copies or substantial portions of the Software.
85
+
86
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
87
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
89
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
90
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
91
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
92
+ THE SOFTWARE.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -13,33 +13,34 @@ bindir: bin
13
13
  cert_chain:
14
14
  - |
15
15
  -----BEGIN CERTIFICATE-----
16
- MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
17
- ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
18
- MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
19
- aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
20
- AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
21
- xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
22
- eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
23
- L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
24
- 9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
25
- E/mljo4zEVKhlTWpJklMIhr55ZRrSarKFuW7en0+tpJrfsYiAmXMJNi4XAYJH7uL
26
- rgJuJwSaa/dMz+VmUoo7VKtSfCoOI+6v5/z0sK3oT6sG6ZwyI47DBq2XqNC6tnAj
27
- w+XmCywiTQrFzMMAvcA7rPI4F0nU1rZId51rOvvfxaONp+wgTi4P8owZLw0/j0m4
28
- 8C20DYi6EYx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XCl
35
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
36
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
37
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
38
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
39
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
40
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
41
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
41
42
  -----END CERTIFICATE-----
42
- date: 2022-05-01 00:00:00.000000000 Z
43
+ date: 2023-01-30 00:00:00.000000000 Z
43
44
  dependencies:
44
45
  - !ruby/object:Gem::Dependency
45
46
  name: protocol-http
@@ -84,47 +85,19 @@ dependencies:
84
85
  - !ruby/object:Gem::Version
85
86
  version: '0'
86
87
  - !ruby/object:Gem::Dependency
87
- name: rspec
88
+ name: sus
88
89
  requirement: !ruby/object:Gem::Requirement
89
90
  requirements:
90
- - - "~>"
91
- - !ruby/object:Gem::Version
92
- version: '3.0'
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '3.0'
100
- - !ruby/object:Gem::Dependency
101
- name: rspec-files
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - "~>"
105
- - !ruby/object:Gem::Version
106
- version: '1.0'
107
- type: :development
108
- prerelease: false
109
- version_requirements: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: '1.0'
114
- - !ruby/object:Gem::Dependency
115
- name: rspec-memory
116
- requirement: !ruby/object:Gem::Requirement
117
- requirements:
118
- - - "~>"
91
+ - - ">="
119
92
  - !ruby/object:Gem::Version
120
- version: '1.0'
93
+ version: '0'
121
94
  type: :development
122
95
  prerelease: false
123
96
  version_requirements: !ruby/object:Gem::Requirement
124
97
  requirements:
125
- - - "~>"
98
+ - - ">="
126
99
  - !ruby/object:Gem::Version
127
- version: '1.0'
100
+ version: '0'
128
101
  description:
129
102
  email:
130
103
  executables: []
@@ -139,6 +112,8 @@ files:
139
112
  - lib/protocol/http1/error.rb
140
113
  - lib/protocol/http1/reason.rb
141
114
  - lib/protocol/http1/version.rb
115
+ - license.md
116
+ - readme.md
142
117
  homepage: https://github.com/socketry/protocol-http1
143
118
  licenses:
144
119
  - MIT
@@ -158,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
133
  - !ruby/object:Gem::Version
159
134
  version: '0'
160
135
  requirements: []
161
- rubygems_version: 3.1.6
136
+ rubygems_version: 3.4.1
162
137
  signing_key:
163
138
  specification_version: 4
164
139
  summary: A low level implementation of the HTTP/1 protocol.
metadata.gz.sig CHANGED
Binary file