diff --git a/zio-http/src/main/scala/zhttp/http/Request.scala b/zio-http/src/main/scala/zhttp/http/Request.scala index 41d3b81e4b..a930ea5ed5 100644 --- a/zio-http/src/main/scala/zhttp/http/Request.scala +++ b/zio-http/src/main/scala/zhttp/http/Request.scala @@ -98,16 +98,10 @@ object Request { remoteAddress: Option[InetAddress] = None, data: HttpData = HttpData.Empty, ): Request = { - val hostHeaders = (url.host, url.port) match { - case (Some(name), None) => Headers.host(name) - case (Some(name), Some(80 | 443)) => Headers.host(name) - case (Some(name), Some(port)) => Headers.host(s"${name}:${port}") - case _ => Headers.empty - } - val m = method - val u = url - val h = headers ++ hostHeaders - val ra = remoteAddress + val m = method + val u = url + val h = headers + val ra = remoteAddress new Request { override def method: Method = m override def url: URL = u diff --git a/zio-http/src/test/scala/zhttp/http/RequestSpec.scala b/zio-http/src/test/scala/zhttp/http/RequestSpec.scala deleted file mode 100644 index 6c90a39710..0000000000 --- a/zio-http/src/test/scala/zhttp/http/RequestSpec.scala +++ /dev/null @@ -1,45 +0,0 @@ -package zhttp.http - -import zio.test.Assertion.{equalTo, isSome} -import zio.test.{DefaultRunnableSpec, _} - -object RequestSpec extends DefaultRunnableSpec { - def spec = suite("Request") { - suite("host header") { - suite("without port") { - test("non-ssl add hostname") { - val url = URL.fromString("http://example.com").getOrElse(null) - val req = Request(url = url) - assert(req.getHost)(isSome(equalTo("example.com"))) - } + - test("ssl add hostname") { - val url = URL.fromString("https://example.com").getOrElse(null) - val req = Request(url = url) - assert(req.getHost)(isSome(equalTo("example.com"))) - } - } + - suite("add port") { - test("non-ssl with non-default port") { - val url = URL.fromString("http://example.com:8090").getOrElse(null) - val req = Request(url = url) - assert(req.getHost)(isSome(equalTo("example.com:8090"))) - } + - test("non-ssl with default port") { - val url = URL.fromString("http://example.com:80").getOrElse(null) - val req = Request(url = url) - assert(req.getHost)(isSome(equalTo("example.com"))) - } + - test("ssl with non-default port") { - val url = URL.fromString("https://example.com:8090").getOrElse(null) - val req = Request(url = url) - assert(req.getHost)(isSome(equalTo("example.com:8090"))) - } + - test("ssl with default port") { - val url = URL.fromString("https://example.com:443").getOrElse(null) - val req = Request(url = url) - assert(req.getHost)(isSome(equalTo("example.com"))) - } - } - } - } -}