| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Review requested:
|
Sorry, something went wrong.
It was added in #14387 by @mcollina so maybe he can add context if that PR doesn't supply the information you need. |
Sorry, something went wrong.
There was a problem hiding this comment.
It doesn't look right to me.
The header should be process before ._send, so it can be ensure either merge with data and pending for first write always receive the same byte.
Sorry, something went wrong.
|
@climba03003 Are you referring to the test, right? |
Sorry, something went wrong.
I means the implementation. The trade-off is process the header with consistence encoding before combine to data. Lines 438 to 587 in a2a954b |
Sorry, something went wrong.
|
I knew about the optimization. I was double checking. |
Sorry, something went wrong.
Inside the code, node.js is always expecting the header is latin1 encoding. In this case, we can expect the non-string branch always utf-8. Since we do the transformation already. // from utf-8 to latin1
const first = Buffer.from('å', 'utf8').toString('latin1')
console.log(first, Buffer.from(first)) // <Buffer c3 83 c2 a5>
// here is what should be done before hand
const second = Buffer.from('å', 'latin1').toString('utf8')
console.log(second, Buffer.from(second)) // <Buffer ef bf bd>
// when data is latin1
const third = Buffer.from('ef bf bd', 'hex')
console.log(third, Buffer.from(third, 'latin1')) // <Buffer ef>
// when data is utf-8 or no encoding
const fouth = Buffer.from('ef bf bd', 'hex')
console.log(fouth, Buffer.from(fouth, 'utf8')) // <Buffer ef>Edit: hmm, buffer truncated doesn't seems correct. |
Sorry, something went wrong.
|
The problem is actually cause by content-disposition allow latin1 but other header is always restricted to ASCII. Maybe special handling of content-disposition in _storeHeader should do the trick without massive change. |
Sorry, something went wrong.
|
@climba03003 I've changed it to check inside processHeader if the header is content-disposition and there is content-length it encodes it in latin1. It will not impact performance but it feels more like a workaround rather than a full solution. |
Sorry, something went wrong.
|
The RFC itself is a special case so I guess we have to act in "workaround way". LGTM. |
Sorry, something went wrong.
|
@nodejs/http Are we good on this? |
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
Sorry, something went wrong.
|
I think it's more of a bug fix than a breaking change... |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
Per HTTP spec, header values are byte strings that should be decoded using isomorphic decode (latin1), not UTF-8. The new interceptor API (onResponseStart) was incorrectly using UTF-8. This change: - Updates parseHeaders and parseRawHeaders to use latin1 encoding - Removes the content-disposition workaround that was needed when headers were inconsistently decoded (see nodejs/node#46528) - Adds tests to verify latin1 decoding behavior Fixes #4753
| Back | FazBrowse Home | New Git URL |
resolves: #46395
I'm not sure what the test test/parallel/test-http-server-response-standalone.js impacted by this change was trying to achieve @Trott