{"action":"created","issue":{"url":"https://api.github.com/repos/Unidata/thredds/issues/271","labels_url":"https://api.github.com/repos/Unidata/thredds/issues/271/labels{/name}","comments_url":"https://api.github.com/repos/Unidata/thredds/issues/271/comments","events_url":"https://api.github.com/repos/Unidata/thredds/issues/271/events","html_url":"https://github.com/Unidata/thredds/pull/271","id":114687683,"number":271,"title":"Fix calls to setContentLength(). (Fixes #197)","user":{"login":"dopplershift","id":221526,"avatar_url":"https://avatars.githubusercontent.com/u/221526?v=3","gravatar_id":"","url":"https://api.github.com/users/dopplershift","html_url":"https://github.com/dopplershift","followers_url":"https://api.github.com/users/dopplershift/followers","following_url":"https://api.github.com/users/dopplershift/following{/other_user}","gists_url":"https://api.github.com/users/dopplershift/gists{/gist_id}","starred_url":"https://api.github.com/users/dopplershift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dopplershift/subscriptions","organizations_url":"https://api.github.com/users/dopplershift/orgs","repos_url":"https://api.github.com/users/dopplershift/repos","events_url":"https://api.github.com/users/dopplershift/events{/privacy}","received_events_url":"https://api.github.com/users/dopplershift/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-11-02T21:26:38Z","updated_at":"2015-11-06T02:45:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Unidata/thredds/pulls/271","html_url":"https://github.com/Unidata/thredds/pull/271","diff_url":"https://github.com/Unidata/thredds/pull/271.diff","patch_url":"https://github.com/Unidata/thredds/pull/271.patch"},"body":"setContentLength() sets the content-length HTTP header, which is defined\r\nas the number of bytes. In all of these changed places, we were passing\r\nin the length of the string, which is the number of characters. This\r\nbreaks in the presence UTF-8 characters, which may be encoded as up to 4\r\nbytes; the result is truncated HTML data (observed in #197).\r\n\r\nOriginal report saw stray characters on HTML view; I was not able to see these in chrome, but they were clear (only `</h` of the closing `</html>` tag) when viewing the HTML source. Two items that may warrant discussion:\r\n- I'd like to add a test, but I'm not sure how best to get a useful one that checks the HTML returned when serving up an appropriate catalog. Pointers welcome.\r\n- I hit all of the users of `setContentLength()`, but I'm not sure if that's all of the problem. Anyone know of anything else easily searchable that could be a victim of this?"},"comment":{"url":"https://api.github.com/repos/Unidata/thredds/issues/comments/154266898","html_url":"https://github.com/Unidata/thredds/pull/271#issuecomment-154266898","issue_url":"https://api.github.com/repos/Unidata/thredds/issues/271","id":154266898,"user":{"login":"DennisHeimbigner","id":905179,"avatar_url":"https://avatars.githubusercontent.com/u/905179?v=3","gravatar_id":"","url":"https://api.github.com/users/DennisHeimbigner","html_url":"https://github.com/DennisHeimbigner","followers_url":"https://api.github.com/users/DennisHeimbigner/followers","following_url":"https://api.github.com/users/DennisHeimbigner/following{/other_user}","gists_url":"https://api.github.com/users/DennisHeimbigner/gists{/gist_id}","starred_url":"https://api.github.com/users/DennisHeimbigner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DennisHeimbigner/subscriptions","organizations_url":"https://api.github.com/users/DennisHeimbigner/orgs","repos_url":"https://api.github.com/users/DennisHeimbigner/repos","events_url":"https://api.github.com/users/DennisHeimbigner/events{/privacy}","received_events_url":"https://api.github.com/users/DennisHeimbigner/received_events","type":"User","site_admin":false},"created_at":"2015-11-06T02:45:44Z","updated_at":"2015-11-06T02:45:44Z","body":"Remember that the body of the message may not ascii or even utf8;\r\nit could be binary, in which case the specified content length may be correct.\r\n"}}