@@ -78,24 +78,28 @@ abstract class ApiClient(
78
78
defaultConnectTimeout : Duration ,
79
79
defaultWriteTimeout : Duration
80
80
): Requester = {
81
+ val optionsWithDefaultTimeouts = options.copy(
82
+ readTimeout = defaultReadTimeout,
83
+ connectTimeout = defaultConnectTimeout,
84
+ writeTimeout = defaultWriteTimeout
85
+ )
86
+
81
87
val algoliaAgent = AlgoliaAgent (BuildInfo .version)
82
88
.addSegment(AgentSegment (clientName, Some (BuildInfo .version)))
83
- .addSegments(options .agentSegments)
89
+ .addSegments(optionsWithDefaultTimeouts .agentSegments)
84
90
85
- val hosts = if (options .hosts.isEmpty) defaultHosts else options .hosts
91
+ val hosts = if (optionsWithDefaultTimeouts .hosts.isEmpty) defaultHosts else optionsWithDefaultTimeouts .hosts
86
92
val statefulHosts = hosts.map(host => StatefulHost (host)).toList
87
-
88
- options.withReadTimeout(Option (options.readTimeout).getOrElse(defaultReadTimeout)).withWriteTimeout(Option (options.writeTimeout).getOrElse(defaultWriteTimeout)).withConnectTimeout(Option (options.connectTimeout).getOrElse(defaultConnectTimeout))
89
-
93
+
90
94
val builder = HttpRequester
91
- .builder(options .customFormats.getOrElse(formats))
95
+ .builder(optionsWithDefaultTimeouts .customFormats.getOrElse(formats))
92
96
.withInterceptor(authInterceptor)
93
97
.withInterceptor(new UserAgentInterceptor (algoliaAgent))
94
98
.withInterceptor(new RetryStrategy (statefulHosts))
95
99
96
- options .requesterConfig.foreach(_(builder))
100
+ optionsWithDefaultTimeouts .requesterConfig.foreach(_(builder))
97
101
98
- builder.build(options )
102
+ builder.build(optionsWithDefaultTimeouts )
99
103
}
100
104
101
105
/** Executes the given request and returns the response.
0 commit comments