Skip to content

Commit

Permalink
Merge pull request akka#19697 from 2m/wip-rendering-warning-2m
Browse files Browse the repository at this point in the history
akka#19639 Supress warnings on custom headers
  • Loading branch information
rkuhn committed Feb 8, 2016
2 parents 1822108 + 6d3e3cf commit cd8eba9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ private[http] class HttpRequestRendererFactory(userAgentHeader: Option[headers.`
case x: `Raw-Request-URI` // we never render this header
renderHeaders(tail, hostHeaderSeen, userAgentSeen, transferEncodingSeen)

case x: CustomHeader if x.renderInRequests
render(x)
case x: CustomHeader
if (x.renderInRequests) render(x)
renderHeaders(tail, hostHeaderSeen, userAgentSeen, transferEncodingSeen)

case x: RawHeader if (x is "content-type") || (x is "content-length") || (x is "transfer-encoding") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ private[http] class HttpResponseRendererFactory(serverHeader: Option[headers.Ser
render(x)
renderHeaders(tail, alwaysClose, connHeader, serverSeen = true, transferEncodingSeen, dateSeen)

case x: CustomHeader if x.renderInResponses
render(x)
case x: CustomHeader
if (x.renderInResponses) render(x)
renderHeaders(tail, alwaysClose, connHeader, serverSeen, transferEncodingSeen, dateSeen)

case x: RawHeader if (x is "content-type") || (x is "content-length") || (x is "transfer-encoding") ||
Expand Down Expand Up @@ -286,4 +286,4 @@ private[http] sealed trait ResponseRenderingOutput
private[http] object ResponseRenderingOutput {
private[http] case class HttpData(bytes: ByteString) extends ResponseRenderingOutput
private[http] case class SwitchToWebSocket(httpResponseBytes: ByteString, handler: Either[Graph[FlowShape[FrameEvent, FrameEvent], Any], Graph[FlowShape[Message, Message], Any]]) extends ResponseRenderingOutput
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import akka.util.ByteString
import akka.http.scaladsl.model.StatusCodes
import akka.stream.testkit.scaladsl.TestSink
import scala.concurrent.Future
import akka.testkit.EventFilter

class WebSocketIntegrationSpec extends AkkaSpec("akka.stream.materializer.debug.fuzzing-mode=off")
with ScalaFutures with ConversionCheckedTripleEquals with Eventually {
Expand Down Expand Up @@ -112,13 +113,16 @@ class WebSocketIntegrationSpec extends AkkaSpec("akka.stream.materializer.debug.
val myPort = binding.localAddress.getPort

val N = 100
val (response, count) = Http().singleWebSocketRequest(
WebSocketRequest("ws://127.0.0.1:" + myPort),
Flow.fromSinkAndSourceMat(
Sink.fold(0)((n, _: Message) n + 1),
Source.repeat(TextMessage("hello")).take(N))(Keep.left))

count.futureValue should ===(N)
EventFilter.warning(pattern = "HTTP header .* is not allowed in responses", occurrences = 0) intercept {
val (response, count) = Http().singleWebSocketRequest(
WebSocketRequest("ws://127.0.0.1:" + myPort),
Flow.fromSinkAndSourceMat(
Sink.fold(0)((n, _: Message) n + 1),
Source.repeat(TextMessage("hello")).take(N))(Keep.left))
count.futureValue should ===(N)
}

binding.unbind()
}

Expand Down

0 comments on commit cd8eba9

Please sign in to comment.