[
https://issues.apache.org/jira/browse/KNOX-3559?focusedWorklogId=1053617&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1053617
]
ASF GitHub Bot logged work on KNOX-3559:
----------------------------------------
Author: ASF GitHub Bot
Created on: 09/Nov/26 18:23
Start Date: 09/Nov/26 18:23
Worklog Time Spent: 10m
Work Description: bonampak commented on code in PR #1498:
URL: https://github.com/apache/knox/pull/1498#discussion_r4516349028
##########
gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletFilterTest.java:
##########
@@ -793,6 +793,46 @@ public void testResponseHtmlBodyRewriteCSSImport() throws
Exception {
assertThat(content, anyOf( is(responseHtmlOne), is(responseHtmlTwo)));
}
+ /*
+ * The Content-Length of the backend response must not be used for the
rewritten body, whatever the case of the
Review Comment:
Can be shorter or longer. (usually longer, as the frontend url is longer
than the original backend url). UrlRewriteResponse has always dropped the
backend Content-Length for this reason.
The problem was that the check was case-sensitive, it only matched
Content-Length.
A backend sending content-length got past it and the client received a
truncated body.
Issue Time Tracking
-------------------
Worklog Id: (was: 1053617)
Time Spent: 40m (was: 0.5h)
> Ignore the backend Content-Length header regardless of case when rewriting
> responses
> ------------------------------------------------------------------------------------
>
> Key: KNOX-3559
> URL: https://issues.apache.org/jira/browse/KNOX-3559
> Project: Apache Knox
> Issue Type: Task
> Components: Server
> Affects Versions: 3.1.0
> Reporter: Tamás Marcinkovics
> Assignee: Tamás Marcinkovics
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> {{UrlRewriteResponse}} drops the backend {{Content-Length}} header because
> rewriting can change the body length. The header name check is case
> sensitive, so a lowercase {{content-length}} header (e.g. from OpenSearch
> Dashboards / Node.js) is passed to the response. When the rewritten body is
> longer, Jetty aborts the response (written N > M content-length) and the
> client gets a failed request.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)