@@ -49,9 +49,15 @@ class Client
49
49
DEFAULT_HOST = 'localhost:9200' . freeze
50
50
51
51
# The default port to use if connecting using a Cloud ID.
52
+ # Updated from 9243 to 443 in client version 7.10.1
52
53
#
53
54
# @since 7.2.0
54
- DEFAULT_CLOUD_PORT = 9243
55
+ DEFAULT_CLOUD_PORT = 443
56
+
57
+ # The default port to use if not otherwise specified.
58
+ #
59
+ # @since 7.2.0
60
+ DEFAULT_PORT = 9200
55
61
56
62
# Returns the transport object.
57
63
#
@@ -243,36 +249,38 @@ def __extract_hosts(hosts_config)
243
249
244
250
def __parse_host ( host )
245
251
host_parts = case host
246
- when String
247
- if host =~ /^[a-z]+\: \/ \/ /
248
- # Construct a new `URI::Generic` directly from the array returned by URI::split.
249
- # This avoids `URI::HTTP` and `URI::HTTPS`, which supply default ports.
250
- uri = URI ::Generic . new ( *URI . split ( host ) )
251
-
252
- { :scheme => uri . scheme ,
253
- :user => uri . user ,
254
- :password => uri . password ,
255
- :host => uri . host ,
256
- :path => uri . path ,
257
- :port => uri . port }
258
- else
259
- host , port = host . split ( ':' )
260
- { :host => host ,
261
- :port => port }
262
- end
263
- when URI
264
- { :scheme => host . scheme ,
265
- :user => host . user ,
266
- :password => host . password ,
267
- :host => host . host ,
268
- :path => host . path ,
269
- :port => host . port }
270
- when Hash
271
- host
272
- else
273
- raise ArgumentError , "Please pass host as a String, URI or Hash -- #{ host . class } given."
274
- end
275
-
252
+ when String
253
+ if host =~ /^[a-z]+\: \/ \/ /
254
+ # Construct a new `URI::Generic` directly from the array returned by URI::split.
255
+ # This avoids `URI::HTTP` and `URI::HTTPS`, which supply default ports.
256
+ uri = URI ::Generic . new ( *URI . split ( host ) )
257
+ default_port = uri . scheme == 'https' ? 443 : DEFAULT_PORT
258
+ {
259
+ scheme : uri . scheme ,
260
+ user : uri . user ,
261
+ password : uri . password ,
262
+ host : uri . host ,
263
+ path : uri . path ,
264
+ port : uri . port || default_port
265
+ }
266
+ else
267
+ host , port = host . split ( ':' )
268
+ { host : host , port : port }
269
+ end
270
+ when URI
271
+ {
272
+ scheme : host . scheme ,
273
+ user : host . user ,
274
+ password : host . password ,
275
+ host : host . host ,
276
+ path : host . path ,
277
+ port : host . port
278
+ }
279
+ when Hash
280
+ host
281
+ else
282
+ raise ArgumentError , "Please pass host as a String, URI or Hash -- #{ host . class } given."
283
+ end
276
284
if @api_key
277
285
# Remove Basic Auth if using API KEY
278
286
host_parts . delete ( :user )
0 commit comments