protocol-http 0.41.0 → 0.43.0

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: ea35499964efa19071138a56a3dfd9b909200c17a96c8eeee65ba8df8c703021
4
- data.tar.gz: e027f09f741d018b567e1428cb7db4bc3241a585e58bf07b8ca4ce9475e64102
3
+ metadata.gz: 7bdd0ca9356d15e047333ae5e070710d5453bece234e484d236656edb984eb3b
4
+ data.tar.gz: eb605cfc6aa68422dd8142ba7e86fb0ec9eef55f8415e8cc0e9066af714a4aa7
5
5
  SHA512:
6
- metadata.gz: 7d717e61a264fe4614c94fd380807b11dc393646b442a16502527bb59642e7bbb21dca3f3e4e6f3fabe7426c6ae14f6bb59722eb5b4e0d8747b13ed3a2c4c523
7
- data.tar.gz: ad0693100a420b1bdfed9439c115a240269bdae9f233b17a54d7c0cadd185f59f364ce8653999da1215fcd99976b5a96803addff78d3c51af5ad6a62a025200c
6
+ metadata.gz: 493688f8e6e8a417bfdb49fd53103e07ccca2f164613e5cea2ce0298b4eb4c4e251add7c1873d178f38b1cfb984267e277c4388f60b9e36b013d1f8bac950b57
7
+ data.tar.gz: '0590a15ef7f6447efc5c84a0c6ce7e796a1b1b8d91975b10f895a5c0d9c450402f7adeb7b504785179e6fe68f776a7113050adc2458dc84e7f4330b6faec4774'
checksums.yaml.gz.sig CHANGED
Binary file
@@ -33,12 +33,12 @@ module Protocol
33
33
  end
34
34
 
35
35
  def close(error = nil)
36
- super.tap do
37
- if @callback
38
- @callback.call(error)
39
- @callback = nil
40
- end
36
+ if @callback
37
+ @callback.call(error)
38
+ @callback = nil
41
39
  end
40
+
41
+ super
42
42
  end
43
43
  end
44
44
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2017-2024, by Samuel Williams.
5
+
6
+ module Protocol
7
+ module HTTP
8
+ # Provide a well defined, cached representation of a peer (address).
9
+ class Peer
10
+ def self.for(io)
11
+ if address = io.remote_address
12
+ return new(address)
13
+ end
14
+ end
15
+
16
+ def initialize(address)
17
+ @address = address
18
+
19
+ if address.ip?
20
+ @ip_address = @address.ip_address
21
+ end
22
+ end
23
+
24
+ attr :address
25
+ attr :ip_address
26
+
27
+ alias remote_address address
28
+ end
29
+ end
30
+ end
@@ -64,6 +64,13 @@ module Protocol
64
64
  # @attribute [Proc] a callback which is called when an interim response is received.
65
65
  attr_accessor :interim_response
66
66
 
67
+ # A request that is generated by a server, may choose to include the peer (address) associated with the request. It should be implemented by a sub-class.
68
+ #
69
+ # @returns [Peer | Nil] The peer (address) associated with the request.
70
+ def peer
71
+ nil
72
+ end
73
+
67
74
  # Send the request to the given connection.
68
75
  def call(connection)
69
76
  connection.call(self)
@@ -52,6 +52,13 @@ module Protocol
52
52
  # @attribute [String | Array(String) | Nil] The protocol, e.g. `"websocket"`, etc.
53
53
  attr_accessor :protocol
54
54
 
55
+ # A response that is generated by a client, may choose to include the peer (address) associated with the response. It should be implemented by a sub-class.
56
+ #
57
+ # @returns [Peer | Nil] The peer (address) associated with the response.
58
+ def peer
59
+ nil
60
+ end
61
+
55
62
  # Whether the response is considered a hijack: the connection has been taken over by the application and the server should not send any more data.
56
63
  def hijack?
57
64
  false
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module HTTP
8
- VERSION = "0.41.0"
8
+ VERSION = "0.43.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.0
4
+ version: 0.43.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -47,7 +47,7 @@ cert_chain:
47
47
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
48
48
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
49
49
  -----END CERTIFICATE-----
50
- date: 2024-10-17 00:00:00.000000000 Z
50
+ date: 2024-11-09 00:00:00.000000000 Z
51
51
  dependencies: []
52
52
  description:
53
53
  email:
@@ -88,6 +88,7 @@ files:
88
88
  - lib/protocol/http/methods.rb
89
89
  - lib/protocol/http/middleware.rb
90
90
  - lib/protocol/http/middleware/builder.rb
91
+ - lib/protocol/http/peer.rb
91
92
  - lib/protocol/http/reference.rb
92
93
  - lib/protocol/http/request.rb
93
94
  - lib/protocol/http/response.rb
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  - !ruby/object:Gem::Version
118
119
  version: '0'
119
120
  requirements: []
120
- rubygems_version: 3.5.11
121
+ rubygems_version: 3.5.22
121
122
  signing_key:
122
123
  specification_version: 4
123
124
  summary: Provides abstractions to handle HTTP protocols.
metadata.gz.sig CHANGED
Binary file