[ruby/net-http] Freeze some constants to improve Ractor compatibility
Freeze `Net::HTTP::SSL_IVNAMES`, `Net::HTTPResponse::CODE_CLASS_TO_OBJ` and `Net::HTTPResponse::CODE_TO_OBJ` to improve Ractor compatibility. This change allows the following code to work: Ractor.new { uri = URI.parse('http://example.com') http = Net::HTTP.new(uri.host, uri.port) http.open_timeout = nil http.read_timeout = nil http.get('/index.html') } https://github.com/ruby/net-http/commit/9f0f5e4b4d
This commit is contained in:
parent
22c09135a8
commit
aa0f689bf4
@ -1529,7 +1529,7 @@ module Net #:nodoc:
|
|||||||
:verify_hostname,
|
:verify_hostname,
|
||||||
] # :nodoc:
|
] # :nodoc:
|
||||||
|
|
||||||
SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym } # :nodoc:
|
SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym }.freeze # :nodoc:
|
||||||
|
|
||||||
# Sets or returns the path to a CA certification file in PEM format.
|
# Sets or returns the path to a CA certification file in PEM format.
|
||||||
attr_accessor :ca_file
|
attr_accessor :ca_file
|
||||||
|
@ -1104,7 +1104,7 @@ class Net::HTTPResponse
|
|||||||
'3' => Net::HTTPRedirection,
|
'3' => Net::HTTPRedirection,
|
||||||
'4' => Net::HTTPClientError,
|
'4' => Net::HTTPClientError,
|
||||||
'5' => Net::HTTPServerError
|
'5' => Net::HTTPServerError
|
||||||
}
|
}.freeze
|
||||||
CODE_TO_OBJ = {
|
CODE_TO_OBJ = {
|
||||||
'100' => Net::HTTPContinue,
|
'100' => Net::HTTPContinue,
|
||||||
'101' => Net::HTTPSwitchProtocol,
|
'101' => Net::HTTPSwitchProtocol,
|
||||||
@ -1170,5 +1170,5 @@ class Net::HTTPResponse
|
|||||||
'508' => Net::HTTPLoopDetected,
|
'508' => Net::HTTPLoopDetected,
|
||||||
'510' => Net::HTTPNotExtended,
|
'510' => Net::HTTPNotExtended,
|
||||||
'511' => Net::HTTPNetworkAuthenticationRequired,
|
'511' => Net::HTTPNetworkAuthenticationRequired,
|
||||||
}
|
}.freeze
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user