Skip to content

Conversation

@halx99
Copy link
Collaborator

@halx99 halx99 commented Sep 30, 2025

  • Add HttpDataCallback type for handling incoming data chunks
  • Implement setDataCallback method in HttpRequest class
  • When data callback is set, response data is not accumulated in _responseData
  • Enable progressive data processing for large file downloads and streaming
  • Maintain backward compatibility - existing code continues to work unchanged

This allows:

  • Memory-efficient handling of large responses
  • Real-time processing of data streams
  • Progress tracking during downloads
  • Custom data storage strategies

Usage:
request->setDataCallback([](HttpResponse* response, const char* data, size_t size) {
// Process data chunks as they arrive
fwrite(data, 1, size, outputFile);
});

Describe your changes

Issue ticket number and link

Checklist before requesting a review

For each PR

  • Add Copyright if it missed:
    - "Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md)."

  • I have performed a self-review of my code.

    Optional:

    • I have checked readme and add important infos to this PR.
    • I have added/adapted some tests too.

For core/new feature PR

  • I have checked readme and add important infos to this PR.
  • I have added thorough tests.

Axmol 3.x ------------------------------------------------------------

For each 3.x PR

  • Check the '#include "axmol.h"' and replace it with the needed headers.

- Add HttpDataCallback type for handling incoming data chunks
- Implement setDataCallback method in HttpRequest class
- When data callback is set, response data is not accumulated in _responseData
- Enable progressive data processing for large file downloads and streaming
- Maintain backward compatibility - existing code continues to work unchanged

This allows:
- Memory-efficient handling of large responses
- Real-time processing of data streams
- Progress tracking during downloads
- Custom data storage strategies

Usage:
request->setDataCallback([](HttpResponse* response, const char* data, size_t size) {
    // Process data chunks as they arrive
    fwrite(data, 1, size, outputFile);
});
@halx99 halx99 added this to the 2.9.0 milestone Sep 30, 2025
@halx99 halx99 added the enhancement New feature or request label Sep 30, 2025
@halx99 halx99 merged commit 0452ac6 into release/2.x Sep 30, 2025
1 check passed
@halx99 halx99 deleted the improve-http-client branch September 30, 2025 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants