Skip to content

Commit

Permalink
Fixes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
d11-amitsingh committed Mar 16, 2021
1 parent 3824516 commit 72bccd9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions zio-http/src/main/scala/zhttp/http/Response.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import zio.Task
import zio.stream.ZStream

import java.io.{PrintWriter, StringWriter}
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter

// RESPONSE
sealed trait Response extends Product with Serializable { self => }

object Response {
private val defaultStatus = Status.OK
private val defaultHeaders = Nil
private val defaultContent = HttpContent.Empty
private val jTrailingHeaders = new JDefaultHttpHeaders(false)
private val defaultStatus = Status.OK
private val defaultHeaders = Nil
private val defaultContent = HttpContent.Empty
private val jTrailingHeaders = new JDefaultHttpHeaders(false)
private val SERVER_NAME: String = "ZIO-Http"

// Constructors
final case class HttpResponse(status: Status, headers: List[Header], content: HttpContent[Any, String])
Expand All @@ -34,6 +37,8 @@ object Response {
val jContentBytBuf = res.content match {
case HttpContent.Complete(data) =>
jHttpHeaders.set(JHttpHeaderNames.CONTENT_LENGTH, data.length())
jHttpHeaders.set(JHttpHeaderNames.SERVER, SERVER_NAME)
jHttpHeaders.set(JHttpHeaderNames.DATE, s"${DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now)}")
JUnpooled.copiedBuffer(data, HTTP_CHARSET)

case _ =>
Expand Down

0 comments on commit 72bccd9

Please sign in to comment.