Quick answer: The string result may truncate large or binary responses. Use http_get_buffer to receive into a pre-allocated buffer, then read bytes via buffer functions. Always check async_load[? "id"] matches your request id.

Here is how to fix GameMaker GMS2 Async HTTP responses that arrive partially or appear truncated. Large JSON payloads or binary downloads do not fit cleanly into the string-based result. Switching to buffer-based receive solves both issues.

The Symptom

HTTP request returns. The string in async_load[? "result"] is shorter than expected. JSON parses fail. Binary downloads end mid-file.

What Causes This

String size limits. Some platforms cap the string size; large responses cut off.

Binary in string. Strings expect UTF-8; binary bytes confuse the conversion and produce corruption.

Multiple requests. Without filtering by request id, a different request’s data overwrites yours.

The Fix

Step 1: Use http_get_buffer for large or binary data.

// Step or button event
buf = buffer_create(1024, buffer_grow, 1);
req_id = http_get_buffer("https://example.com/data.bin", buf);

The buffer grows as needed; binary or large responses fit.

Step 2: Handle in Async Networking event.

// Async Networking event
if (async_load[? "id"] != req_id) exit;
if (async_load[? "status"] != 0) exit;   // 0 = completed

var _http = async_load[? "http_status"];
if (_http != 200) {
    show_debug_message("HTTP error: " + string(_http));
    exit;
}

// Read from buffer
buffer_seek(buf, buffer_seek_start, 0);
var _json = buffer_read(buf, buffer_string);
// or buffer_read other types for binary

Step 3: Handle status codes. async_load[? “status”] is 0 for completed, 1 for in-progress (incremental data), -1 for error. Check before processing.

Step 4: Free the buffer when done.

buffer_delete(buf);

Step 5: For very large downloads, monitor progress.

if (async_load[? "status"] == 1) {
    // in-progress: progress bar
    var _have = async_load[? "sizeDownloaded"];
    var _total = async_load[? "contentLength"];
    if (_total > 0) progress = _have / _total;
}

“Strings cap. Buffers grow. http_get_buffer for anything large or binary; check id, status, http_status before reading.”

Related Issues

For buffer write encoding, see Buffer String Encoding. For surface lifecycle, see Surface Lost.

http_get_buffer. Check id and status. Read via buffer_read. Big payloads survive.