No9 / harmon

middleware for node-http-proxy to modify the remote website response with trumpet
Other
424 stars 62 forks source link

Content Length not deleted on HTML rewrite if HTML Only #56

Open mmartinsky opened 3 years ago

mmartinsky commented 3 years ago
      /* Sniff out the content-type header.
       * If the response is HTML, we're safe to modify it.
       */
      if (!_htmlOnly && res.isHtml()) {
        res.removeHeader('Content-Length');
        delete headers['content-length'];
      }

If I have an HTML response, but I'm targeted to HTML only, the content length won't get overwritten, which leads to "Error: Transferred a partial file" errors on the response.

Why is this guarded by !_htmlOnly?

kilobyte2007 commented 1 year ago

This looks like a mistake and breaks some sites. Shouldn't it just be? @No9 can you please take a look?

 /* Sniff out the content-type header.
 * If the response is HTML, we're safe to modify it.
 */
if (res.isHtml()) {
  res.removeHeader('Content-Length');
  delete headers['content-length'];
}
evantobin commented 1 year ago

@kilobyte2007 I can confirm that change works