getBytes crashing after http.customRequest

Forewarning: I’m very new to Haxe.

I’m trying to use http.customRequest (with the intention of later making PUT and DELETE requests). But when I try to access the result bytes I get a segmentation fault with C++ and a NullPointerException with Java.

I’ve googled for some other uses of customRequest, and what I’m doing doesn’t seem wrong, but clearly it is.

class Main {
    static function main() {
        var req = new haxe.Http("");
        var responseBytes = new;

        req.onError = function(err) {
            trace(err); // Java says NullPointerException

        req.onStatus = function(status) {
            trace("About to get bytes");

            // Removing these lines prevents the errors
            var b = responseBytes.getBytes();
            trace("Got the bytes");
            trace(b.length); // Shouldn't be empty, but is

        req.customRequest(false, responseBytes, null, "PUT");

I’ve tried this with the current release and with HEAD (via Brew).

I think my command lines are pretty basic:

$ haxe -cp src -main Main -java bin/java
$ java -jar bin/java/Main.jar
src/Main.hx:12: About to get bytes
src/Main.hx:16: Got the bytes
src/Main.hx:17: 0
src/Main.hx:7: onError
src/Main.hx:8: java.lang.NullPointerException

$ haxe -cp src -main Main -cpp bin/cpp
$ ./bin/cpp/Main
src/Main.hx:12: About to get bytes
src/Main.hx:16: Got the bytes
src/Main.hx:17: 0
[1]    54544 segmentation fault  ./bin/cpp/Main

I’d really appreciate any guidance.

(Edit: I originally said that the error trace in Java was causing a NPE, but of course it’s not – that’s just what the error message is.)

In case it’s useful, here’s the differently broken output for Python:

$ haxe -cp src -main Main -python bin/
$ python3 bin/
About to trace err
SSLError(1, '[SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1045)')

I fixed it by moving the getBytes() to below the customRequest() call.