gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated: Decompression error handling.


From: gnunet
Subject: [libeufin] branch master updated: Decompression error handling.
Date: Tue, 26 Sep 2023 21:47:57 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new 6e2bf1a4 Decompression error handling.
6e2bf1a4 is described below

commit 6e2bf1a4b94a2ca07429a816e4059ef538240af0
Author: MS <ms@taler.net>
AuthorDate: Tue Sep 26 21:47:30 2023 +0200

    Decompression error handling.
---
 bank/src/main/kotlin/tech/libeufin/bank/Main.kt | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt 
b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
index d69fd15a..b0d9d02c 100644
--- a/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
+++ b/bank/src/main/kotlin/tech/libeufin/bank/Main.kt
@@ -181,11 +181,20 @@ val corebankDecompressionPlugin = 
createApplicationPlugin("RequestingBodyDecompr
     onCallReceive { call ->
         transformBody { data ->
             if (call.request.headers[HttpHeaders.ContentEncoding] == 
"deflate") {
-                val brc = withContext(Dispatchers.IO) {
-                    val inflated = InflaterInputStream(data.toInputStream())
-                    @Suppress("BlockingMethodInNonBlockingContext")
-                    val bytes = inflated.readAllBytes()
-                    ByteReadChannel(bytes)
+                val brc = try {
+                    withContext(Dispatchers.IO) {
+                        val inflated = 
InflaterInputStream(data.toInputStream())
+
+                        @Suppress("BlockingMethodInNonBlockingContext")
+                        val bytes = inflated.readAllBytes()
+                        ByteReadChannel(bytes)
+                    }
+                } catch (e: Exception) {
+                    logger.error("Deflated request failed to inflate: 
${e.message}")
+                    throw badRequest(
+                        hint = "Could not inflate request",
+                        talerErrorCode = TalerErrorCode.TALER_EC_END // FIXME: 
provide dedicated EC.
+                    )
                 }
                 brc
             } else data

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]