Title: ungzipping buffer with trailing garbage throws error · Issue #7502 · nodejs/node · GitHub
Open Graph Title: ungzipping buffer with trailing garbage throws error · Issue #7502 · nodejs/node
X Title: ungzipping buffer with trailing garbage throws error · Issue #7502 · nodejs/node
Description: One site sends a gzipped html page and I try to ungzip page for further processing but zlib throws error incorrect header check. Error happens due to extra data after gzipped page. Yes, gzipped data is not valid, since have trailing data...
Open Graph Description: One site sends a gzipped html page and I try to ungzip page for further processing but zlib throws error incorrect header check. Error happens due to extra data after gzipped page. Yes, gzipped dat...
X Description: One site sends a gzipped html page and I try to ungzip page for further processing but zlib throws error incorrect header check. Error happens due to extra data after gzipped page. Yes, gzipped dat...
Opengraph URL: https://github.com/nodejs/node/issues/7502
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ungzipping buffer with trailing garbage throws error","articleBody":"One site sends a gzipped html page and I try to ungzip page for further processing but zlib throws error `incorrect header check`. Error happens due to extra data after gzipped page. Yes, gzipped data is not valid, since have trailing data, but in other hand, browser eat that normally.\n\nMinimal example:\n\n``` javascript\nvar zlib = require('zlib')\n\n// from test-zlib-from-gzip-with-trailing-garbage.js\nbufOk = Buffer.concat([\n zlib.gzipSync(\"abc\"),\n Buffer(10).fill(0)\n]);\n\nbufWrong = Buffer.concat([\n zlib.gzipSync(\"abc\"),\n Buffer(\"\\n \\n\\n\\n\\n \\n\")\n]);\n\n// wil not raise Error\nconsole.log(\"bufOk:\", zlib.gunzipSync(bufOk).toString());\n\n// will raise Error('incorrect header check')\nconsole.log(\"bufWrong:\", zlib.gunzipSync(bufWrong).toString());\n```\n\nAlso live example:\n\n``` javascript\nvar req = require('request')\nreq.get('http://irsural.ru', {gzip: true}, (err, res, body) =\u003e {\n if (err != null) {\n console.log('Error:', err);\n return \n }\n console.log(body);\n});\n```\n\nIn other languages (for example, python - [requests](https://github.com/kennethreitz/requests/blob/efb4af01271c8c0ddf49457c7096a5bc91edbdad/requests/packages/urllib3/response.py#L50)) I can set `windowBits` to `16 + zlib.Z_MAX_WINDOWBITS` but `node` strictly restricted `windowBits` from 0 to 15 even in addon.\n## \n- **Version**: v6.2.2\n- **Platform**: linux, x86_64\n- **Subsystem**: zlib\n","author":{"url":"https://github.com/horpto","@type":"Person","name":"horpto"},"datePublished":"2016-06-30T16:38:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/7502/node/issues/7502"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:53ece057-d9c3-1360-ea97-efde35575a77 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A52:1846F5:E8A115:EDBEE3:6A4DC326 |
| html-safe-nonce | 3f450d467a701335863d71e3f866b93b81084a36ce0d165e1a51f9ae91f5c7d3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTUyOjE4NDZGNTpFOEExMTU6RURCRUUzOjZBNERDMzI2IiwidmlzaXRvcl9pZCI6IjE4MDMzNjYyMjcxNjgzMTQxNTAiLCJyZWdpb25fZWRnZSI6InNlYSIsInJlZ2lvbl9yZW5kZXIiOiJzZWEifQ== |
| visitor-hmac | 1361e7bc04df3e938c3dd832f7f40b4f9eb473dcdc0ae8c7a9cd1219f4bb63f5 |
| hovercard-subject-tag | issue:163210222 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/7502/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f5b50464d5578ae0ad9881fabd6926e11b9da91d7bf7ecf6a98aaf8f37f21130/nodejs/node/issues/7502 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f5b50464d5578ae0ad9881fabd6926e11b9da91d7bf7ecf6a98aaf8f37f21130/nodejs/node/issues/7502 |
| og:image:alt | One site sends a gzipped html page and I try to ungzip page for further processing but zlib throws error incorrect header check. Error happens due to extra data after gzipped page. Yes, gzipped dat... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | horpto |
| hostname | github.com |
| expected-hostname | github.com |
| None | 06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width