Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Sep 28, 2024
1 parent ca31dc0 commit 8ea35a2
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions zio-http/shared/src/main/scala/zio/http/Header.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ sealed trait Header {

object Header {

def validateHeaders(headers: Headers): ZIO[Any, Response, Unit] = {
val invalidHeaderChars = Set('\r', '\n', '\u0000')
val hasInvalidChar = headers.toList.exists { header =>
header.renderedValue.exists(invalidHeaderChars.contains)
}

if (hasInvalidChar) {
ZIO.fail(Response.status(Status.BadRequest))
} else {
ZIO.unit
}
}

sealed trait HeaderType {
type HeaderValue <: Header

Expand Down Expand Up @@ -78,19 +91,6 @@ object Header {
override def render(value: HeaderValue): String = value.value.toString
}

def validateHeaders(headers: Headers): ZIO[Any, Response, Unit] = {
val invalidHeaderChars = Set('\r', '\n', '\u0000')
val hasInvalidChar = headers.toList.exists { header =>
header.renderedValue.exists(invalidHeaderChars.contains)
}

if (hasInvalidChar) {
ZIO.fail(Response.status(Status.BadRequest))
} else {
ZIO.unit
}
}

private[http] override def headerNameAsCharSequence: CharSequence = customName
private[http] override def renderedValueAsCharSequence: CharSequence = value

Expand Down

0 comments on commit 8ea35a2

Please sign in to comment.