protocol-http 0.26.1 → 0.26.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78df5c09889fbba8150a172d085d646850e286ff263d75651240346e918e94b3
4
- data.tar.gz: ef5914cbb06341c27974ac57ebb9f2799beac0976d84081166d6dbd3c1d32530
3
+ metadata.gz: cd49532afd66aa61fc45281ce3fd9493e241790cd3daaf59c071793f91b5b42a
4
+ data.tar.gz: a8b0cefa5ad518293558a66a2db77fb4bd9ef3ba381134d9051d24ad1bcb64a5
5
5
  SHA512:
6
- metadata.gz: 1d84a1f3eb31ca1f44ef6f390bae189d1bea595478a1486bcd04f41ef2c088e2f8d1989ed279056d9a30be688bacbd7c3481cd18484222e88ed93195a81016fd
7
- data.tar.gz: dcbf2a95b67dd0f2631e5f9339b16c06149e686bf8ff9bc5525bc389cc78692b5a62fcdbc1b830f3f0d7a8ce37472fd3d9ac281ec1c981ce3e558afeb55485d4
6
+ metadata.gz: 8d243e058e7cd0dd9825c44de883e5badf0df4aa150608ffdc034e4c0259412d64699cb97e0132e2d9307bcf874a2ce67f03e02046d00c761415d71c5c0a7941
7
+ data.tar.gz: 0d29c9fd133dede2b2d7a545405df8e64dcfb497477c1252bb34e41fffac7fc9540142b9d1961a146d2e4afcedc86fb4cb9ce2e75d55a5c1a5e4ac4c0ced8659
checksums.yaml.gz.sig CHANGED
Binary file
@@ -25,24 +25,20 @@ module Protocol
25
25
  end
26
26
 
27
27
  def finish
28
- if @body
29
- result = super
30
-
31
- @callback.call
32
-
33
- @body = nil
34
-
35
- return result
28
+ super.tap do
29
+ if @callback
30
+ @callback.call
31
+ @callback = nil
32
+ end
36
33
  end
37
34
  end
38
35
 
39
36
  def close(error = nil)
40
- if @body
41
- super
42
-
43
- @callback.call(error)
44
-
45
- @body = nil
37
+ super.tap do
38
+ if @callback
39
+ @callback.call(error)
40
+ @callback = nil
41
+ end
46
42
  end
47
43
  end
48
44
  end
@@ -92,6 +92,16 @@ module Protocol
92
92
  return buffer
93
93
  end
94
94
  end
95
+
96
+ def as_json
97
+ {
98
+ class: self.class.name,
99
+ length: self.length,
100
+ stream: self.stream?,
101
+ ready: self.ready?,
102
+ empty: self.empty?
103
+ }
104
+ end
95
105
  end
96
106
  end
97
107
  end
@@ -51,6 +51,13 @@ module Protocol
51
51
  @body.read
52
52
  end
53
53
 
54
+ def as_json
55
+ {
56
+ class: self.class.name,
57
+ body: @body&.as_json
58
+ }
59
+ end
60
+
54
61
  def inspect
55
62
  @body.inspect
56
63
  end
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
+ # Copyright, 2024, by Earlopain.
5
6
 
6
7
  module Protocol
7
8
  module HTTP
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2023, by Samuel Williams.
4
+ # Copyright, 2019-2024, by Samuel Williams.
5
+ # Copyright, 2024, by Thomas Morgan.
5
6
 
6
7
  require_relative 'split'
7
8
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2023, by Samuel Williams.
4
+ # Copyright, 2023-2024, by Samuel Williams.
5
5
 
6
6
  require 'time'
7
7
 
@@ -299,6 +299,8 @@ module Protocol
299
299
  end
300
300
  end
301
301
 
302
+ alias as_json to_h
303
+
302
304
  def inspect
303
305
  "#<#{self.class} #{@fields.inspect}>"
304
306
  end
@@ -73,6 +73,19 @@ module Protocol
73
73
  @method != Methods::POST && (@body.nil? || @body.empty?)
74
74
  end
75
75
 
76
+ def as_json
77
+ {
78
+ scheme: @scheme,
79
+ authority: @authority,
80
+ method: @method,
81
+ path: @path,
82
+ version: @version,
83
+ headers: @headers&.as_json,
84
+ body: @body&.as_json,
85
+ protocol: @protocol
86
+ }
87
+ end
88
+
76
89
  def to_s
77
90
  "#{@scheme}://#{@authority}: #{@method} #{@path} #{@version}"
78
91
  end
@@ -104,6 +104,16 @@ module Protocol
104
104
  Response[500, Headers['content-type' => 'text/plain'], ["#{exception.class}: #{exception.message}"]]
105
105
  end
106
106
 
107
+ def as_json
108
+ {
109
+ version: @version,
110
+ status: @status,
111
+ headers: @headers&.as_json,
112
+ body: @body&.as_json,
113
+ protocol: @protocol
114
+ }
115
+ end
116
+
107
117
  def to_s
108
118
  "#{@status} #{@version}"
109
119
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2018-2023, by Samuel Williams.
4
+ # Copyright, 2018-2024, by Samuel Williams.
5
5
 
6
6
  module Protocol
7
7
  module HTTP
8
- VERSION = "0.26.1"
8
+ VERSION = "0.26.3"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -8,8 +8,9 @@ Copyright, 2020-2023, by Bruno Sutic.
8
8
  Copyright, 2022, by Herrick Fang.
9
9
  Copyright, 2022, by Dan Olson.
10
10
  Copyright, 2023, by Genki Takiuchi.
11
- Copyright, 2023, by Thomas Morgan.
11
+ Copyright, 2023-2024, by Thomas Morgan.
12
12
  Copyright, 2023, by Marcelo Junior.
13
+ Copyright, 2024, by Earlopain.
13
14
 
14
15
  Permission is hereby granted, free of charge, to any person obtaining a copy
15
16
  of this software and associated documentation files (the "Software"), to deal
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.1
4
+ version: 0.26.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - Thomas Morgan
8
9
  - Bruno Sutic
9
10
  - Herrick Fang
10
- - Thomas Morgan
11
11
  - Bryan Powell
12
12
  - Dan Olson
13
+ - Earlopain
13
14
  - Genki Takiuchi
14
15
  - Marcelo Junior
15
16
  - Olle Jonsson
@@ -46,7 +47,7 @@ cert_chain:
46
47
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
47
48
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
48
49
  -----END CERTIFICATE-----
49
- date: 2024-02-07 00:00:00.000000000 Z
50
+ date: 2024-04-16 00:00:00.000000000 Z
50
51
  dependencies: []
51
52
  description:
52
53
  email:
metadata.gz.sig CHANGED
Binary file