@@ -442,30 +442,25 @@ void HTTPRequest::_request_done(int p_status, int p_code, const PackedStringArra
442
442
is_compressed = false ;
443
443
}
444
444
445
- const PackedByteArray *data = nullptr ;
446
-
447
445
if (accept_gzip && is_compressed && p_data.size () > 0 ) {
448
446
// Decompress request body
449
- PackedByteArray * decompressed = memnew (PackedByteArray) ;
450
- int result = Compression::decompress_dynamic (decompressed, body_size_limit, p_data.ptr (), p_data.size (), mode);
447
+ PackedByteArray decompressed;
448
+ int result = Compression::decompress_dynamic (& decompressed, body_size_limit, p_data.ptr (), p_data.size (), mode);
451
449
if (result == OK) {
452
- data = decompressed;
450
+ emit_signal (SNAME (" request_completed" ), p_status, p_code, p_headers, decompressed);
451
+ return ;
453
452
} else if (result == -5 ) {
454
453
WARN_PRINT (" Decompressed size of HTTP response body exceeded body_size_limit" );
455
454
p_status = RESULT_BODY_SIZE_LIMIT_EXCEEDED;
456
455
// Just return the raw data if we failed to decompress it
457
- data = &p_data;
458
456
} else {
459
457
WARN_PRINT (" Failed to decompress HTTP response body" );
460
458
p_status = RESULT_BODY_DECOMPRESS_FAILED;
461
459
// Just return the raw data if we failed to decompress it
462
- data = &p_data;
463
460
}
464
- } else {
465
- data = &p_data;
466
461
}
467
462
468
- emit_signal (SNAME (" request_completed" ), p_status, p_code, p_headers, *data );
463
+ emit_signal (SNAME (" request_completed" ), p_status, p_code, p_headers, p_data );
469
464
}
470
465
471
466
void HTTPRequest::_notification (int p_what) {
0 commit comments