Skip to content

Commit

Permalink
doing string truncation for max http response size manually to suppor…
Browse files Browse the repository at this point in the history
…t backporting

Signed-off-by: Dennis Toepker <[email protected]>
  • Loading branch information
toepkerd-zz committed Feb 23, 2024
1 parent 7ce174d commit 364d170
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ class DestinationHttpClient {
@Throws(IOException::class)
fun getResponseString(response: CloseableHttpResponse): String {
val entity: HttpEntity = response.entity ?: return "{}"
val responseString = EntityUtils.toString(entity, PluginSettings.maxHttpResponseSize / 2) // Java char is 2 bytes
var responseString = EntityUtils.toString(entity)
if (responseString.length > (PluginSettings.maxHttpResponseSize / 2)) { // Java char is 2 bytes
responseString = responseString.substring(0, PluginSettings.maxHttpResponseSize / 2)
}
// DeliveryStatus need statusText must not be empty, convert empty response to {}
return if (responseString.isNullOrEmpty()) "{}" else responseString
}
Expand Down

0 comments on commit 364d170

Please sign in to comment.