{"action":"created","issue":{"url":"https://api.github.com/repos/nfriedly/node-unblocker/issues/54","labels_url":"https://api.github.com/repos/nfriedly/node-unblocker/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/nfriedly/node-unblocker/issues/54/comments","events_url":"https://api.github.com/repos/nfriedly/node-unblocker/issues/54/events","html_url":"https://github.com/nfriedly/node-unblocker/issues/54","id":112360622,"number":54,"title":"Charset troubles ","user":{"login":"vitaliydz","id":11947891,"avatar_url":"https://avatars.githubusercontent.com/u/11947891?v=3","gravatar_id":"","url":"https://api.github.com/users/vitaliydz","html_url":"https://github.com/vitaliydz","followers_url":"https://api.github.com/users/vitaliydz/followers","following_url":"https://api.github.com/users/vitaliydz/following{/other_user}","gists_url":"https://api.github.com/users/vitaliydz/gists{/gist_id}","starred_url":"https://api.github.com/users/vitaliydz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitaliydz/subscriptions","organizations_url":"https://api.github.com/users/vitaliydz/orgs","repos_url":"https://api.github.com/users/vitaliydz/repos","events_url":"https://api.github.com/users/vitaliydz/events{/privacy}","received_events_url":"https://api.github.com/users/vitaliydz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-20T12:48:26Z","updated_at":"2015-10-21T13:07:00Z","closed_at":"2015-10-21T12:46:39Z","body":"In file charsets.js i find one problem for my proxy. Into snippet:\r\n\r\n            var charset = contentTypes.getCharset(data);\r\n\r\n            // todo: consider just rewriting headers and meta tags to utf8 instead of reencoding things\r\n            if (iconv.encodingExists(charset)) {\r\n                // happy case, we know the encoding right away, so we can just return decode/recode streams\r\n                data.charset = charset;\r\n                data.stream = data.stream.pipe(iconv.decodeStream(charset));\r\n                debug('decoding %s charset via iconv stream', charset);\r\n            } else if (mayContainMeta(data.contentType)) {\r\n                debug('decoding unknown charset via iconv html stream');\r\n                data.charsetDecoder = new IconvHtmlStream();\r\n                data.charsetDecoder.on('charset', function(charset) {\r\n                    // note: while the recode stream will accept content before this and just output utf-8, it shouldn't actually receive any data because the decode stream buffers until *after* this event\r\n                    data.charset = charset;\r\n                });\r\n                data.stream = data.stream.pipe(data.charsetDecoder);\r\n            } else {\r\n                debug('no charset info available, assuming utf8');\r\n                // semi-happy case. we know the content needs parsed but have no way of knowing it's charset. Hopefully .toString() will be good enough. No recoding\r\n                data.stream = data.stream.pipe(new PassThrough({\r\n                    encoding: 'utf8'\r\n                }));\r\n            }\r\n\r\nWhen charset = undefined, executing snippet in `else if`  block. But in this case, stream hang up on this place = > data.charsetDecoder.on('charset', ...).\r\n\r\nFor resolving this trouble I add new condition into if ... else ... processing:  \r\nif (charset && iconv.encodingExists(charset)) { ... }\r\nelse if(charset && mayContainMeta(data.contentType)){ ... } \r\nelse { ... }\r\n\r\nIf u have best idea for this trouble, please, add your resolve in next commit\r\n\r\nSorry for my english)"},"comment":{"url":"https://api.github.com/repos/nfriedly/node-unblocker/issues/comments/149888316","html_url":"https://github.com/nfriedly/node-unblocker/issues/54#issuecomment-149888316","issue_url":"https://api.github.com/repos/nfriedly/node-unblocker/issues/54","id":149888316,"user":{"login":"nfriedly","id":114976,"avatar_url":"https://avatars.githubusercontent.com/u/114976?v=3","gravatar_id":"","url":"https://api.github.com/users/nfriedly","html_url":"https://github.com/nfriedly","followers_url":"https://api.github.com/users/nfriedly/followers","following_url":"https://api.github.com/users/nfriedly/following{/other_user}","gists_url":"https://api.github.com/users/nfriedly/gists{/gist_id}","starred_url":"https://api.github.com/users/nfriedly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfriedly/subscriptions","organizations_url":"https://api.github.com/users/nfriedly/orgs","repos_url":"https://api.github.com/users/nfriedly/repos","events_url":"https://api.github.com/users/nfriedly/events{/privacy}","received_events_url":"https://api.github.com/users/nfriedly/received_events","type":"User","site_admin":false},"created_at":"2015-10-21T13:07:00Z","updated_at":"2015-10-21T13:07:00Z","body":"Ok, I figured it out and added a test for it - the code that was supposed to find the `<meta charset...` tag had a bug where if it never saw a `<meta...` or `</head>` tag, it would buffer indefinitely instead of just passing the data along. \r\n\r\nBut now another test is failing on the CI (but passing on my laptop), so I've got some more debugging to do..."}}