From 4cf567209cef6c69f3eb8ca81479fc700ddca33a Mon Sep 17 00:00:00 2001 From: Ignasi Marimon-Clos Date: Thu, 15 Feb 2018 20:07:54 +0100 Subject: [PATCH] Allows Sec-WebSocket-Extensions in requests --- .../main/scala/akka/http/scaladsl/model/headers/headers.scala | 2 +- .../scala/akka/http/scaladsl/model/headers/HeaderSpec.scala | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/akka-http-core/src/main/scala/akka/http/scaladsl/model/headers/headers.scala b/akka-http-core/src/main/scala/akka/http/scaladsl/model/headers/headers.scala index d6ae928e316..ffd1c35a4d8 100644 --- a/akka-http-core/src/main/scala/akka/http/scaladsl/model/headers/headers.scala +++ b/akka-http-core/src/main/scala/akka/http/scaladsl/model/headers/headers.scala @@ -766,7 +766,7 @@ private[http] object `Sec-WebSocket-Extensions` extends ModeledCompanion[`Sec-We */ @InternalApi private[http] final case class `Sec-WebSocket-Extensions`(extensions: immutable.Seq[WebSocketExtension]) - extends ResponseHeader { + extends RequestResponseHeader { require(extensions.nonEmpty, "Sec-WebSocket-Extensions.extensions must not be empty") import `Sec-WebSocket-Extensions`.extensionsRenderer protected[http] def renderValue[R <: Rendering](r: R): r.type = r ~~ extensions diff --git a/akka-http-core/src/test/scala/akka/http/scaladsl/model/headers/HeaderSpec.scala b/akka-http-core/src/test/scala/akka/http/scaladsl/model/headers/HeaderSpec.scala index 17972833004..6b8b84a3c0d 100644 --- a/akka-http-core/src/test/scala/akka/http/scaladsl/model/headers/HeaderSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/scaladsl/model/headers/HeaderSpec.scala @@ -7,7 +7,8 @@ package akka.http.scaladsl.model.headers import akka.http.impl.util._ import org.scalatest._ import java.net.InetAddress -import akka.http.scaladsl.model._ + +import akka.http.scaladsl.model.{ headers, _ } class HeaderSpec extends FreeSpec with Matchers { "ModeledCompanion should" - { @@ -132,6 +133,7 @@ class HeaderSpec extends FreeSpec with Matchers { `Proxy-Authorization`(BasicHttpCredentials("johan", "correcthorsebatterystaple")), Range(RangeUnits.Bytes, Vector(ByteRange(1, 1024))), Referer(Uri("http://example.com/")), + `Sec-WebSocket-Extensions`(Vector(WebSocketExtension("permessage-deflate"), WebSocketExtension("client_max_window_bits"))), `Sec-WebSocket-Protocol`(Vector("chat", "superchat")), `Sec-WebSocket-Key`("dGhlIHNhbXBsZSBub25jZQ"), `Sec-WebSocket-Version`(Vector(13)),