You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/protocol/http/body/stream.rb
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@
10
10
moduleProtocol
11
11
moduleHTTP
12
12
moduleBody
13
-
# The input stream is an IO-like object which contains the raw HTTP POST data. When applicable, its external encoding must be “ASCII-8BIT” and it must be opened in binary mode, for Ruby 1.9 compatibility. The input stream must respond to gets, each, read and rewind.
13
+
# The input stream is an IO-like object which contains the raw HTTP POST data. When applicable, its external encoding must be "ASCII-8BIT" and it must be opened in binary mode, for Ruby 1.9 compatibility. The input stream must respond to gets, each, read and rewind.
Copy file name to clipboardExpand all lines: lib/protocol/http/header/etag.rb
+18-2Lines changed: 18 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,25 @@ module Header
10
10
#
11
11
# The `etag` header provides a unique identifier for a specific version of a resource, typically used for cache validation or conditional requests. It can be either a strong or weak validator as defined in RFC 9110.
12
12
classETag < String
13
-
# Replaces the current value of the `etag` header with the specified value.
13
+
# Parses a raw header value from the wire.
14
14
#
15
-
# @parameter value [String] the new value for the `etag` header.
15
+
# @parameter value [String] the raw header value.
16
+
# @returns [ETag] a new instance.
17
+
defself.parse(value)
18
+
self.new(value)
19
+
end
20
+
21
+
# Coerces a value into a parsed header object.
22
+
#
23
+
# @parameter value [String] the value to coerce.
24
+
# @returns [ETag] a parsed header object.
25
+
defself.coerce(value)
26
+
self.new(value.to_s)
27
+
end
28
+
29
+
# Replaces the current value of the `etag` header with a raw wire-format string.
30
+
#
31
+
# @parameter value [String] a raw wire-format value for the `etag` header.
Copy file name to clipboardExpand all lines: lib/protocol/http/header/multiple.rb
+35-6Lines changed: 35 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -10,18 +10,47 @@ module Header
10
10
#
11
11
# This isn't a specific header but is used as a base for headers that store multiple values, such as cookies. The values are split and stored as an array internally, and serialized back to a newline-separated string when needed.
12
12
classMultiple < Array
13
-
# Initializes the multiple header with the given value. As the header key-value pair can only contain one value, the value given here is added to the internal array, and subsequent values can be added using the `<<` operator.
13
+
# Parses a raw header value from the wire.
14
14
#
15
-
# @parameter value [String] the raw header value.
16
-
definitialize(value)
15
+
# Multiple headers receive each value as a separate header entry on the wire, so this method takes a single string value and creates a new instance containing it.
16
+
#
17
+
# @parameter value [String] a single raw header value from the wire.
18
+
# @returns [Multiple] a new instance containing the parsed value.
19
+
defself.parse(value)
20
+
self.new([value])
21
+
end
22
+
23
+
# Coerces a value into a parsed header object.
24
+
#
25
+
# This method is used by the Headers class when setting values via `[]=` to convert application values into the appropriate policy type.
26
+
#
27
+
# @parameter value [String | Array] the value to coerce.
28
+
# @returns [Multiple] a parsed header object.
29
+
defself.coerce(value)
30
+
casevalue
31
+
whenArray
32
+
self.new(value)
33
+
else
34
+
self.parse(value.to_s)
35
+
end
36
+
end
37
+
38
+
# Initializes the multiple header with already-parsed values.
39
+
#
40
+
# @parameter value [Array | Nil] an array of header values, or `nil` for an empty header.
41
+
definitialize(value=nil)
17
42
super()
18
43
19
-
self << value
44
+
ifvalue
45
+
self.concat(value)
46
+
end
20
47
end
21
48
22
-
# Serializes the stored values into a newline-separated string.
49
+
# Converts the parsed header value into a raw wire-format string.
50
+
#
51
+
# Multiple headers are transmitted as separate header entries on the wire, so this serializes to a newline-separated string for storage.
23
52
#
24
-
# @returns [String] the serialized representation of the header values.
53
+
# @returns [String] a raw wire-format value (newline-separated string).
0 commit comments