6
6
using System . Collections . Generic ;
7
7
using System . Collections . Specialized ;
8
8
using System . Security . Cryptography . X509Certificates ;
9
+
9
10
using Elastic . Transport . Extensions ;
10
11
11
12
namespace Elastic . Transport ;
@@ -108,7 +109,6 @@ public interface IRequestConfiguration
108
109
/// </summary>
109
110
TimeSpan ? RequestTimeout { get ; }
110
111
111
-
112
112
/// <summary> Specifies the headers from the response that should be parsed. </summary>
113
113
HeadersList ? ResponseHeadersToParse { get ; }
114
114
@@ -163,6 +163,48 @@ public record RequestConfiguration : IRequestConfiguration
163
163
/// <summary> The default ping timeout when the connection is over HTTPS. Defaults to 5 seconds </summary>
164
164
public static readonly TimeSpan DefaultPingTimeoutOnSsl = TimeSpan . FromSeconds ( 5 ) ;
165
165
166
+ /// <inheritdoc cref="IRequestConfiguration"/>
167
+ public RequestConfiguration ( )
168
+ {
169
+ }
170
+
171
+ /// <inheritdoc cref="IRequestConfiguration"/>
172
+ public RequestConfiguration ( IRequestConfiguration config )
173
+ {
174
+ #if NET8_0_OR_GREATER
175
+ ArgumentNullException . ThrowIfNull ( config ) ;
176
+ #else
177
+ if ( config is null )
178
+ throw new ArgumentNullException ( nameof ( config ) ) ;
179
+ #endif
180
+
181
+ Accept = config . Accept ;
182
+ AllowedStatusCodes = config . AllowedStatusCodes ;
183
+ Authentication = config . Authentication ;
184
+ ClientCertificates = config . ClientCertificates ;
185
+ ContentType = config . ContentType ;
186
+ DisableDirectStreaming = config . DisableDirectStreaming ;
187
+ DisableAuditTrail = config . DisableAuditTrail ;
188
+ DisablePings = config . DisablePings ;
189
+ DisableSniff = config . DisableSniff ;
190
+ HttpPipeliningEnabled = config . HttpPipeliningEnabled ;
191
+ EnableHttpCompression = config . EnableHttpCompression ;
192
+ ForceNode = config . ForceNode ;
193
+ MaxRetries = config . MaxRetries ;
194
+ MaxRetryTimeout = config . MaxRetryTimeout ;
195
+ OpaqueId = config . OpaqueId ;
196
+ PingTimeout = config . PingTimeout ;
197
+ RequestTimeout = config . RequestTimeout ;
198
+ RunAs = config . RunAs ;
199
+ ThrowExceptions = config . ThrowExceptions ;
200
+ TransferEncodingChunked = config . TransferEncodingChunked ;
201
+ Headers = ( config . Headers is null ) ? null : new NameValueCollection ( config . Headers ) ;
202
+ EnableTcpStats = config . EnableTcpStats ;
203
+ EnableThreadPoolStats = config . EnableThreadPoolStats ;
204
+ ResponseHeadersToParse = ( config . ResponseHeadersToParse is null ) ? null : new HeadersList ( config . ResponseHeadersToParse ) ;
205
+ ParseAllHeaders = config . ParseAllHeaders ;
206
+ RequestMetaData = config . RequestMetaData ;
207
+ }
166
208
167
209
/// <inheritdoc />
168
210
public string ? Accept { get ; init ; }
@@ -189,7 +231,7 @@ public record RequestConfiguration : IRequestConfiguration
189
231
public bool ? DisablePings { get ; init ; }
190
232
191
233
/// <inheritdoc />
192
- public bool ? DisablePing { get ; init ; }
234
+ public bool ? DisablePing { get ; init ; } // TODO: ?
193
235
194
236
/// <inheritdoc />
195
237
public bool ? DisableSniff { get ; init ; }
@@ -198,7 +240,7 @@ public record RequestConfiguration : IRequestConfiguration
198
240
public bool ? HttpPipeliningEnabled { get ; init ; }
199
241
200
242
/// <inheritdoc />
201
- public bool ? EnableHttpPipelining { get ; init ; } = true ;
243
+ public bool ? EnableHttpPipelining { get ; init ; } = true ; // TODO: ?
202
244
203
245
/// <inheritdoc />
204
246
public bool ? EnableHttpCompression { get ; init ; }
@@ -247,7 +289,6 @@ public record RequestConfiguration : IRequestConfiguration
247
289
248
290
/// <inheritdoc />
249
291
public RequestMetaData ? RequestMetaData { get ; init ; }
250
-
251
292
}
252
293
253
294
/// <inheritdoc cref="IRequestConfiguration"/>
@@ -256,6 +297,40 @@ public class RequestConfigurationDescriptor : IRequestConfiguration
256
297
/// <inheritdoc cref="IRequestConfiguration"/>
257
298
public RequestConfigurationDescriptor ( ) { }
258
299
300
+ /// <inheritdoc cref="IRequestConfiguration"/>
301
+ public RequestConfigurationDescriptor ( IRequestConfiguration ? config )
302
+ {
303
+ if ( config is null )
304
+ return ;
305
+
306
+ _accept = config . Accept ;
307
+ _allowedStatusCodes = config . AllowedStatusCodes ;
308
+ _authentication = config . Authentication ;
309
+ _clientCertificates = config . ClientCertificates ;
310
+ _contentType = config . ContentType ;
311
+ _disableDirectStreaming = config . DisableDirectStreaming ;
312
+ _disableAuditTrail = config . DisableAuditTrail ;
313
+ _disablePings = config . DisablePings ;
314
+ _disableSniff = config . DisableSniff ;
315
+ _httpPipeliningEnabled = config . HttpPipeliningEnabled ;
316
+ _enableHttpCompression = config . EnableHttpCompression ;
317
+ _forceNode = config . ForceNode ;
318
+ _maxRetries = config . MaxRetries ;
319
+ _maxRetryTimeout = config . MaxRetryTimeout ;
320
+ _opaqueId = config . OpaqueId ;
321
+ _pingTimeout = config . PingTimeout ;
322
+ _requestTimeout = config . RequestTimeout ;
323
+ _runAs = config . RunAs ;
324
+ _throwExceptions = config . ThrowExceptions ;
325
+ _transferEncodingChunked = config . TransferEncodingChunked ;
326
+ _headers = ( config . Headers is null ) ? null : new NameValueCollection ( config . Headers ) ;
327
+ _enableTcpStats = config . EnableTcpStats ;
328
+ _enableThreadPoolStats = config . EnableThreadPoolStats ;
329
+ _responseHeadersToParse = ( config . ResponseHeadersToParse is null ) ? null : new HeadersList ( config . ResponseHeadersToParse ) ;
330
+ _parseAllHeaders = config . ParseAllHeaders ;
331
+ _requestMetaData = config . RequestMetaData ;
332
+ }
333
+
259
334
private string ? _accept ;
260
335
private IReadOnlyCollection < int > ? _allowedStatusCodes ;
261
336
private AuthorizationHeader ? _authentication ;
@@ -282,11 +357,10 @@ public RequestConfigurationDescriptor() { }
282
357
private RequestMetaData ? _requestMetaData ;
283
358
284
359
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value
285
- private bool ? _enableHttpCompression ;
286
- private TimeSpan ? _maxRetryTimeout ;
360
+ private bool ? _enableHttpCompression ; // TODO: ?
361
+ private TimeSpan ? _maxRetryTimeout ; // TODO: ?
287
362
#pragma warning restore CS0649 // Field is never assigned to, and will always have its default value
288
363
289
-
290
364
/// <inheritdoc cref="IRequestConfiguration.RunAs"/>
291
365
public RequestConfigurationDescriptor RunAs ( string username )
292
366
{
0 commit comments