Only close AttachmentCipher streams if using incremental MAC.
This commit is contained in:
parent
4572ae5886
commit
8b8d62f598
1 changed files with 8 additions and 6 deletions
|
@ -41,8 +41,9 @@ class DigestingRequestBody(
|
|||
override fun writeTo(sink: BufferedSink) {
|
||||
val digestStream = ByteArrayOutputStream()
|
||||
val inner = SkippingOutputStream(contentStart, sink.outputStream())
|
||||
val outputStream: DigestingOutputStream = if (outputStreamFactory is AttachmentCipherOutputStreamFactory) {
|
||||
outputStreamFactory.createIncrementalFor(inner, contentLength, digestStream)
|
||||
val isIncremental = outputStreamFactory is AttachmentCipherOutputStreamFactory
|
||||
val outputStream: DigestingOutputStream = if (isIncremental) {
|
||||
(outputStreamFactory as AttachmentCipherOutputStreamFactory).createIncrementalFor(inner, contentLength, digestStream)
|
||||
} else {
|
||||
outputStreamFactory.createFor(inner)
|
||||
}
|
||||
|
@ -61,10 +62,11 @@ class DigestingRequestBody(
|
|||
}
|
||||
|
||||
outputStream.flush()
|
||||
if (isIncremental) {
|
||||
outputStream.close()
|
||||
digestStream.close()
|
||||
|
||||
incrementalDigest = digestStream.toByteArray()
|
||||
}
|
||||
transmittedDigest = outputStream.transmittedDigest
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue