@@ -237,12 +237,29 @@ public class HTTPClient {
237
237
/// - deadline: Point in time by which the request must complete.
238
238
/// - logger: The logger to use for this request.
239
239
public func get( url: String , deadline: NIODeadline ? = nil , logger: Logger ) -> EventLoopFuture < Response > {
240
- do {
241
- let request = try Request ( url: url, method: . GET)
242
- return self . execute ( request: request, deadline: deadline, logger: logger)
243
- } catch {
244
- return self . eventLoopGroup. next ( ) . makeFailedFuture ( error)
245
- }
240
+ return self . execute ( url: url, method: . GET, deadline: deadline, logger: logger)
241
+ }
242
+
243
+ /// Execute `GET` request to a unix domain socket path, using the specified URL as the request to send to the server.
244
+ ///
245
+ /// - parameters:
246
+ /// - socketPath: The path to the unix domain socket to connect to.
247
+ /// - url: The URL path and query that will be sent to the server.
248
+ /// - deadline: Point in time by which the request must complete.
249
+ /// - logger: The logger to use for this request.
250
+ public func get( socketPath: String , url: String , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
251
+ return self . execute ( socketPath: socketPath, url: url, method: . GET, deadline: deadline, logger: logger)
252
+ }
253
+
254
+ /// Execute `GET` request to a unix domain socket path over TLS, using the specified URL as the request to send to the server.
255
+ ///
256
+ /// - parameters:
257
+ /// - secureSocketPath: The path to the unix domain socket to connect to.
258
+ /// - url: The URL path and query that will be sent to the server.
259
+ /// - deadline: Point in time by which the request must complete.
260
+ /// - logger: The logger to use for this request.
261
+ public func get( secureSocketPath: String , url: String , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
262
+ return self . execute ( secureSocketPath: secureSocketPath, url: url, method: . GET, deadline: deadline, logger: logger)
246
263
}
247
264
248
265
/// Execute `POST` request using specified URL.
@@ -263,12 +280,31 @@ public class HTTPClient {
263
280
/// - deadline: Point in time by which the request must complete.
264
281
/// - logger: The logger to use for this request.
265
282
public func post( url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ) -> EventLoopFuture < Response > {
266
- do {
267
- let request = try HTTPClient . Request ( url: url, method: . POST, body: body)
268
- return self . execute ( request: request, deadline: deadline, logger: logger)
269
- } catch {
270
- return self . eventLoopGroup. next ( ) . makeFailedFuture ( error)
271
- }
283
+ return self . execute ( url: url, method: . POST, body: body, deadline: deadline, logger: logger)
284
+ }
285
+
286
+ /// Execute `POST` request to a unix domain socket path, using the specified URL as the request to send to the server.
287
+ ///
288
+ /// - parameters:
289
+ /// - socketPath: The path to the unix domain socket to connect to.
290
+ /// - url: The URL path and query that will be sent to the server.
291
+ /// - body: Request body.
292
+ /// - deadline: Point in time by which the request must complete.
293
+ /// - logger: The logger to use for this request.
294
+ public func post( socketPath: String , url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
295
+ return self . execute ( socketPath: socketPath, url: url, method: . POST, body: body, deadline: deadline, logger: logger)
296
+ }
297
+
298
+ /// Execute `POST` request to a unix domain socket path over TLS, using the specified URL as the request to send to the server.
299
+ ///
300
+ /// - parameters:
301
+ /// - secureSocketPath: The path to the unix domain socket to connect to.
302
+ /// - url: The URL path and query that will be sent to the server.
303
+ /// - body: Request body.
304
+ /// - deadline: Point in time by which the request must complete.
305
+ /// - logger: The logger to use for this request.
306
+ public func post( secureSocketPath: String , url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
307
+ return self . execute ( secureSocketPath: secureSocketPath, url: url, method: . POST, body: body, deadline: deadline, logger: logger)
272
308
}
273
309
274
310
/// Execute `PATCH` request using specified URL.
@@ -289,12 +325,31 @@ public class HTTPClient {
289
325
/// - deadline: Point in time by which the request must complete.
290
326
/// - logger: The logger to use for this request.
291
327
public func patch( url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ) -> EventLoopFuture < Response > {
292
- do {
293
- let request = try HTTPClient . Request ( url: url, method: . PATCH, body: body)
294
- return self . execute ( request: request, deadline: deadline, logger: logger)
295
- } catch {
296
- return self . eventLoopGroup. next ( ) . makeFailedFuture ( error)
297
- }
328
+ return self . execute ( url: url, method: . PATCH, body: body, deadline: deadline, logger: logger)
329
+ }
330
+
331
+ /// Execute `PATCH` request to a unix domain socket path, using the specified URL as the request to send to the server.
332
+ ///
333
+ /// - parameters:
334
+ /// - socketPath: The path to the unix domain socket to connect to.
335
+ /// - url: The URL path and query that will be sent to the server.
336
+ /// - body: Request body.
337
+ /// - deadline: Point in time by which the request must complete.
338
+ /// - logger: The logger to use for this request.
339
+ public func patch( socketPath: String , url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
340
+ return self . execute ( socketPath: socketPath, url: url, method: . PATCH, body: body, deadline: deadline, logger: logger)
341
+ }
342
+
343
+ /// Execute `PATCH` request to a unix domain socket path over TLS, using the specified URL as the request to send to the server.
344
+ ///
345
+ /// - parameters:
346
+ /// - secureSocketPath: The path to the unix domain socket to connect to.
347
+ /// - url: The URL path and query that will be sent to the server.
348
+ /// - body: Request body.
349
+ /// - deadline: Point in time by which the request must complete.
350
+ /// - logger: The logger to use for this request.
351
+ public func patch( secureSocketPath: String , url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
352
+ return self . execute ( secureSocketPath: secureSocketPath, url: url, method: . PATCH, body: body, deadline: deadline, logger: logger)
298
353
}
299
354
300
355
/// Execute `PUT` request using specified URL.
@@ -315,12 +370,31 @@ public class HTTPClient {
315
370
/// - deadline: Point in time by which the request must complete.
316
371
/// - logger: The logger to use for this request.
317
372
public func put( url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ) -> EventLoopFuture < Response > {
318
- do {
319
- let request = try HTTPClient . Request ( url: url, method: . PUT, body: body)
320
- return self . execute ( request: request, deadline: deadline, logger: logger)
321
- } catch {
322
- return self . eventLoopGroup. next ( ) . makeFailedFuture ( error)
323
- }
373
+ return self . execute ( url: url, method: . PUT, body: body, deadline: deadline, logger: logger)
374
+ }
375
+
376
+ /// Execute `PUT` request to a unix domain socket path, using the specified URL as the request to send to the server.
377
+ ///
378
+ /// - parameters:
379
+ /// - socketPath: The path to the unix domain socket to connect to.
380
+ /// - url: The URL path and query that will be sent to the server.
381
+ /// - body: Request body.
382
+ /// - deadline: Point in time by which the request must complete.
383
+ /// - logger: The logger to use for this request.
384
+ public func put( socketPath: String , url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
385
+ return self . execute ( socketPath: socketPath, url: url, method: . PUT, body: body, deadline: deadline, logger: logger)
386
+ }
387
+
388
+ /// Execute `PUT` request to a unix domain socket path over TLS, using the specified URL as the request to send to the server.
389
+ ///
390
+ /// - parameters:
391
+ /// - secureSocketPath: The path to the unix domain socket to connect to.
392
+ /// - url: The URL path and query that will be sent to the server.
393
+ /// - body: Request body.
394
+ /// - deadline: Point in time by which the request must complete.
395
+ /// - logger: The logger to use for this request.
396
+ public func put( secureSocketPath: String , url: String , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
397
+ return self . execute ( secureSocketPath: secureSocketPath, url: url, method: . PUT, body: body, deadline: deadline, logger: logger)
324
398
}
325
399
326
400
/// Execute `DELETE` request using specified URL.
@@ -339,9 +413,85 @@ public class HTTPClient {
339
413
/// - deadline: The time when the request must have been completed by.
340
414
/// - logger: The logger to use for this request.
341
415
public func delete( url: String , deadline: NIODeadline ? = nil , logger: Logger ) -> EventLoopFuture < Response > {
416
+ return self . execute ( url: url, method: . DELETE, deadline: deadline, logger: logger)
417
+ }
418
+
419
+ /// Execute `DELETE` request to a unix domain socket path, using the specified URL as the request to send to the server.
420
+ ///
421
+ /// - parameters:
422
+ /// - socketPath: The path to the unix domain socket to connect to.
423
+ /// - url: The URL path and query that will be sent to the server.
424
+ /// - deadline: The time when the request must have been completed by.
425
+ /// - logger: The logger to use for this request.
426
+ public func delete( socketPath: String , url: String , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
427
+ return self . execute ( socketPath: socketPath, url: url, method: . DELETE, deadline: deadline, logger: logger)
428
+ }
429
+
430
+ /// Execute `DELETE` request to a unix domain socket path over TLS, using the specified URL as the request to send to the server.
431
+ ///
432
+ /// - parameters:
433
+ /// - secureSocketPath: The path to the unix domain socket to connect to.
434
+ /// - url: The URL path and query that will be sent to the server.
435
+ /// - deadline: The time when the request must have been completed by.
436
+ /// - logger: The logger to use for this request.
437
+ public func delete( secureSocketPath: String , url: String , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
438
+ return self . execute ( secureSocketPath: secureSocketPath, url: url, method: . DELETE, deadline: deadline, logger: logger)
439
+ }
440
+
441
+ /// Execute arbitrary HTTP request using specified URL.
442
+ ///
443
+ /// - parameters:
444
+ /// - url: Request url.
445
+ /// - method: Request method.
446
+ /// - body: Request body.
447
+ /// - deadline: Point in time by which the request must complete.
448
+ /// - logger: The logger to use for this request.
449
+ public func execute( url: String , method: HTTPMethod , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
450
+ do {
451
+ let request = try Request ( url: url, method: method, body: body)
452
+ return self . execute ( request: request, deadline: deadline, logger: logger ?? HTTPClient . loggingDisabled)
453
+ } catch {
454
+ return self . eventLoopGroup. next ( ) . makeFailedFuture ( error)
455
+ }
456
+ }
457
+
458
+ /// Execute arbitrary HTTP+UNIX request to a unix domain socket path, using the specified URL as the request to send to the server.
459
+ ///
460
+ /// - parameters:
461
+ /// - socketPath: The path to the unix domain socket to connect to.
462
+ /// - url: The URL path and query that will be sent to the server.
463
+ /// - method: Request method.
464
+ /// - body: Request body.
465
+ /// - deadline: Point in time by which the request must complete.
466
+ /// - logger: The logger to use for this request.
467
+ public func execute( socketPath: String , url: String , method: HTTPMethod , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
468
+ do {
469
+ guard let url = URL ( httpURLWithSocketPath: socketPath, uri: url) else {
470
+ throw HTTPClientError . invalidURL
471
+ }
472
+ let request = try Request ( url: url, method: method, body: body)
473
+ return self . execute ( request: request, deadline: deadline, logger: logger ?? HTTPClient . loggingDisabled)
474
+ } catch {
475
+ return self . eventLoopGroup. next ( ) . makeFailedFuture ( error)
476
+ }
477
+ }
478
+
479
+ /// Execute arbitrary HTTPS+UNIX request to a unix domain socket path over TLS, using the specified URL as the request to send to the server.
480
+ ///
481
+ /// - parameters:
482
+ /// - secureSocketPath: The path to the unix domain socket to connect to.
483
+ /// - url: The URL path and query that will be sent to the server.
484
+ /// - method: Request method.
485
+ /// - body: Request body.
486
+ /// - deadline: Point in time by which the request must complete.
487
+ /// - logger: The logger to use for this request.
488
+ public func execute( secureSocketPath: String , url: String , method: HTTPMethod , body: Body ? = nil , deadline: NIODeadline ? = nil , logger: Logger ? = nil ) -> EventLoopFuture < Response > {
342
489
do {
343
- let request = try Request ( url: url, method: . DELETE)
344
- return self . execute ( request: request, deadline: deadline, logger: logger)
490
+ guard let url = URL ( httpsURLWithSocketPath: secureSocketPath, uri: url) else {
491
+ throw HTTPClientError . invalidURL
492
+ }
493
+ let request = try Request ( url: url, method: method, body: body)
494
+ return self . execute ( request: request, deadline: deadline, logger: logger ?? HTTPClient . loggingDisabled)
345
495
} catch {
346
496
return self . eventLoopGroup. next ( ) . makeFailedFuture ( error)
347
497
}
0 commit comments