[MGNLEE-743] Avoid duplication of headers Created: 09/Jan/23 Updated: 08/Feb/24 Resolved: 17/Jan/23 |
|
| Status: | Closed |
| Project: | Magnolia DX Core |
| Component/s: | None |
| Affects Version/s: | 6.2.27 |
| Fix Version/s: | 6.3.0, 6.2.28 |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Mercedes Iruela | Assignee: | Canh Nguyen |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | maintenance | ||
| Σ Remaining Estimate: | Not Specified | Remaining Estimate: | Not Specified |
| Σ Time Spent: | Not Specified | Time Spent: | Not Specified |
| Σ Original Estimate: | Not Specified | Original Estimate: | Not Specified |
| Issue Links: |
|
|||||||||||||||||||||||||
| Sub-Tasks: |
|
|||||||||||||||||||||||||
| Template: |
|
|||||||||||||||||||||||||
| Acceptance criteria: |
Empty
|
|||||||||||||||||||||||||
| Task DoD: |
[X]*
Doc/release notes changes? Comment present?
[X]*
Downstream builds green?
[X]*
Solution information and context easily available?
[X]*
Tests
[X]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
|||||||||||||||||||||||||
| Bug DoR: |
[X]*
Steps to reproduce, expected, and actual results filled
[X]*
Affected version filled
|
|||||||||||||||||||||||||
| Epic Link: | Support | |||||||||||||||||||||||||
| Sprint: | DevX 28 | |||||||||||||||||||||||||
| Story Points: | 0 | |||||||||||||||||||||||||
| Team: | ||||||||||||||||||||||||||
| Work Started: | ||||||||||||||||||||||||||
| Description |
|
When there are multiple requests, headers are duplicated in info.magnolia.cms.filters.AddHeadersFilter because org.apache.http.HttpMessage.addHeader(String, String) is used to add headers. Another case is info.magnolia.enterprise.registration.RegistrationFilter that includes "X-Magnolia-Registration", after that, here, the header is duplicated due to info.magnolia.module.cache.filter.CacheResponseWrapper.replayHeadersAndStatus(HttpServletResponse target), here info.magnolia.cms.util.RequestHeaderUtil.setHeader(HttpServletResponse, String, Object) where the header is added when it was already added to the request. An easy way to reproduce it is installing Sitemesh, after installing this module, after request will have duplicate headers Although, the protocol defines: Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one "field-name: field-value" pair, without changing the semantics of the message, by appending each subsequent field-value to the first, each separated by a comma. The order in which header fields with the same field-name are received is therefore significant to the interpretation of the combined field value, and thus a proxy MUST NOT change the order of these field values when a message is forwarded. It may be a good practice to check if a header already exists with the same value. There is a utility class to work with headers that might help: info.magnolia.cms.util.RequestHeaderUtil Workaround: |