protect against errors in chunking or gunziping... without this there can be hangs
changing valid char to XML 1.1 rather than 1.0 and reverting changes from recent PR