fixes #6

use encoding found in HTTP headers in first iteration