Found, that haxe.Http don't handle gzip encoded responses. So, in onData callback string is messy if response Content-Encoding is gzip. IMHO, it have to be mentioned in docs somehow. It can save a lot of time to those who will face this problem.

My solution to handle this:
class Main {
public static function main() {
var r = new haxe.Http("http://cf.gcdn.co/cf/145/assets_remote/assetsRepository.json");
r.onStatus = s -> trace(r.responseHeaders);
r.onBytes = bytes -> {
trace(r.responseHeaders["Content-Encoding"]);
if (r.responseHeaders["Content-Encoding"] == "gzip") {
var reader = new format.gz.Reader(new haxe.io.BytesInput(bytes, 0, bytes.length));
var s = reader.read();
trace(s);
}
};
}
}
Btw, we can link cookbok with similair solution to docs.
P.S: it works but only for sys . For nodejs target there are no responseHeaders property in haxe.Http so haven't idea how to handle it.
Found, that haxe.Http don't handle
gzipencoded responses. So, inonDatacallback string is messy if responseContent-Encodingisgzip. IMHO, it have to be mentioned in docs somehow. It can save a lot of time to those who will face this problem.My solution to handle this:
Btw, we can link cookbok with similair solution to docs.
P.S: it works but only for
sys. For nodejs target there are noresponseHeadersproperty inhaxe.Httpso haven't idea how to handle it.