Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
add Host to HTTPClient requests
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 committed Apr 17, 2018
2 parents 41a406f + 5010c50 commit 29606de
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Sources/HTTP/Responder/HTTPClient.swift
Expand Up @@ -127,10 +127,8 @@ private final class HTTPClientRequestSerializer: ChannelOutboundHandler {
func write(ctx: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?) {
let req = unwrapOutboundIn(data)
var headers = req.headers
if let contentLength = req.body.count {
headers.replaceOrAdd(name: .contentLength, value: contentLength.description)
} else {
headers.replaceOrAdd(name: .contentLength, value: "0")
if headers[.host].isEmpty, let host = req.url.host {
headers.add(name: .host, value: host)
}
var httpHead = HTTPRequestHead(version: req.version, method: req.method, uri: req.url.absoluteString)
httpHead.headers = headers
Expand Down

0 comments on commit 29606de

Please sign in to comment.