replace PushPullStage with GraphStage in HttpServerBluePrint
This commit is contained in:
parent
e2c1638171
commit
cc2e0e8d32
1 changed files with 20 additions and 10 deletions
|
|
@ -518,17 +518,27 @@ private[http] object HttpServerBluePrint {
|
||||||
def with100ContinueTrigger[T <: ParserOutput](createEntity: EntityCreator[T, RequestEntity]) =
|
def with100ContinueTrigger[T <: ParserOutput](createEntity: EntityCreator[T, RequestEntity]) =
|
||||||
StreamedEntityCreator {
|
StreamedEntityCreator {
|
||||||
createEntity.compose[Source[T, NotUsed]] {
|
createEntity.compose[Source[T, NotUsed]] {
|
||||||
_.via(Flow[T].transform(() ⇒ new PushPullStage[T, T] {
|
_.via(new GraphStage[FlowShape[T, T]] {
|
||||||
|
val in: Inlet[T] = Inlet("GraphStage.in")
|
||||||
|
val out: Outlet[T] = Outlet("GraphStage.out")
|
||||||
|
override val shape: FlowShape[T, T] = FlowShape(in, out)
|
||||||
|
|
||||||
|
override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
|
||||||
|
new GraphStageLogic(shape) with InHandler with OutHandler {
|
||||||
private var oneHundredContinueSent = false
|
private var oneHundredContinueSent = false
|
||||||
def onPush(elem: T, ctx: Context[T]) = ctx.push(elem)
|
|
||||||
def onPull(ctx: Context[T]) = {
|
override def onPush(): Unit = push(out, grab(in))
|
||||||
|
override def onPull(): Unit = {
|
||||||
if (!oneHundredContinueSent) {
|
if (!oneHundredContinueSent) {
|
||||||
oneHundredContinueSent = true
|
oneHundredContinueSent = true
|
||||||
emit100ContinueResponse.invoke(())
|
emit100ContinueResponse.invoke(())
|
||||||
}
|
}
|
||||||
ctx.pull()
|
pull(in)
|
||||||
}
|
}
|
||||||
}).named("expect100continueTrigger"))
|
|
||||||
|
setHandlers(in, out, this)
|
||||||
|
}
|
||||||
|
}.named("expect100continueTrigger"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue