Browse Source

fix headers response

herlanS_ 4 years ago
parent
commit
c641525514

+ 8 - 7
src/main/kotlin/co/id/datacomsolusindo/ipphonebridge/BridgeFIlter.kt

@@ -108,18 +108,19 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
 
                 val resFromSocket = Singletons.responseQue[reqId]
 
-                resFromSocket!!.body?.let {
-                    res.outputStream.write(it)
-                }
-
-                res.status = resFromSocket.statusCode
+                res.status = resFromSocket!!.statusCode
                 resFromSocket.headers?.let {
-                    it.entries.filter { f -> resFromSocket.statusCode < 400 || f.key == "Content-Type" }.forEach { en ->
-                        println(en.key + " -> " + en.value.joinToString(","))
+                    it.entries
+                            .filter { f -> resFromSocket.statusCode < 400 || (resFromSocket.statusCode >= 400 && f.key == "Content-Type") }
+                            .forEach { en ->
                         res.setHeader(en.key, en.value.joinToString(","))
                     }
                 }
 
+                resFromSocket.body?.let {
+                    res.outputStream.write(it)
+                }
+
                 res.flushBuffer()
 
                 Singletons.requestInstance.remove(reqId)