NavidJalali commented on code in PR #684:
URL: https://github.com/apache/pekko-http/pull/684#discussion_r2116031855


##########
http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala:
##########
@@ -1226,3 +1225,70 @@ final case class `X-Real-Ip`(address: RemoteAddress) 
extends jm.headers.XRealIp
   def renderValue[R <: Rendering](r: R): r.type = r ~~ address
   protected def companion = `X-Real-Ip`
 }
+
+object Trailer extends ModeledCompanion[Trailer] {
+  private implicit val trailersRenderer: Renderer[immutable.Iterable[String]] =
+    Renderer.defaultSeqRenderer[String]
+
+  def apply(values: immutable.Seq[String]): Trailer = {
+    val clean = values.map(_.trim).filter(_.nonEmpty)
+    val (forbidden, allowed) = clean.partition(name => 
isForbidden(name.toRootLowerCase))
+    if (clean.isEmpty)
+      throw new IllegalArgumentException(s"Trailer values must not be empty: 
No valid header names specified")
+    else if (forbidden.nonEmpty) {
+      val forbiddenInput = forbidden.mkString("[", ", ", "]")
+      throw new IllegalArgumentException(
+        s"Trailer values must not contain forbidden header names: Trailer 
contained $forbiddenInput")
+    } else new Trailer(allowed)

Review Comment:
   Can you think of a better place to put it?  I only put it here because I 
didn't know of a better place



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to