Skip to content

Commit

Permalink
#1367 Fix MISP export
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed May 26, 2020
1 parent fd087c0 commit 4564863
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions misp/client/src/main/scala/org/thp/misp/client/Base64Flow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Base64EncoderFlow extends GraphStage[FlowShape[ByteString, ByteString]] {
val encoder: Base64.Encoder = Base64.getEncoder

override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) {
var remainingBytes: ByteString = ByteString.empty
var remainingBytes: ByteString = ByteString.empty
var upstreamIsFinished: Boolean = false

setHandler(
in,
Expand All @@ -35,15 +36,21 @@ class Base64EncoderFlow extends GraphStage[FlowShape[ByteString, ByteString]] {
}
}

override def onUpstreamFinish(): Unit = {
push(out, ByteString(encoder.encode(remainingBytes.toArray)))
completeStage
}
override def onUpstreamFinish(): Unit =
upstreamIsFinished = true
}
)
setHandler(
out,
new OutHandler {
override def onPull(): Unit =
if (!upstreamIsFinished)
pull(in)
else {
push(out, ByteString(encoder.encode(remainingBytes.toArray)))
completeStage
}
}
)
setHandler(out, new OutHandler {
override def onPull(): Unit =
pull(in)
})
}
}

0 comments on commit 4564863

Please sign in to comment.