From e1393d01ad2c4727bb55db62cdeea8a4ae1fa461 Mon Sep 17 00:00:00 2001 From: Alexander Steiner Date: Sat, 7 May 2022 14:57:47 +0200 Subject: [PATCH] Fix missing Host header for Docker requests --- Sources/DockerClientSwift/APIs/DockerClient.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/DockerClientSwift/APIs/DockerClient.swift b/Sources/DockerClientSwift/APIs/DockerClient.swift index d176cbc..0011684 100644 --- a/Sources/DockerClientSwift/APIs/DockerClient.swift +++ b/Sources/DockerClientSwift/APIs/DockerClient.swift @@ -33,7 +33,7 @@ public class DockerClient { /// - Returns: Returns an `EventLoopFuture` of the expected result definied by the `Endpoint`. internal func run(_ endpoint: T) throws -> EventLoopFuture { logger.info("Execute Endpoint: \(endpoint.path)") - return client.execute(endpoint.method, socketPath: daemonSocket, urlPath: "/v1.40/\(endpoint.path)", body: endpoint.body.map {HTTPClient.Body.data( try! $0.encode())}, logger: logger, headers: HTTPHeaders([("Content-Type", "application/json")])) + return client.execute(endpoint.method, socketPath: daemonSocket, urlPath: "/v1.40/\(endpoint.path)", body: endpoint.body.map {HTTPClient.Body.data( try! $0.encode())}, logger: logger, headers: HTTPHeaders([("Content-Type", "application/json"), ("Host", "localhost")])) .logResponseBody(logger) .decode(as: T.Response.self) } @@ -44,7 +44,7 @@ public class DockerClient { /// - Returns: Returns an `EventLoopFuture` of the expected result definied and transformed by the `PipelineEndpoint`. internal func run(_ endpoint: T) throws -> EventLoopFuture { logger.info("Execute PipelineEndpoint: \(endpoint.path)") - return client.execute(endpoint.method, socketPath: daemonSocket, urlPath: "/v1.40/\(endpoint.path)", body: endpoint.body.map {HTTPClient.Body.data( try! $0.encode())}, logger: logger, headers: HTTPHeaders([("Content-Type", "application/json")])) + return client.execute(endpoint.method, socketPath: daemonSocket, urlPath: "/v1.40/\(endpoint.path)", body: endpoint.body.map {HTTPClient.Body.data( try! $0.encode())}, logger: logger, headers: HTTPHeaders([("Content-Type", "application/json"), ("Host", "localhost")])) .logResponseBody(logger) .mapString(map: endpoint.map(data: )) }