libfetch 0.0.0
A lightweight asynchronous HTTP/1.1 client library implementing a subset of the WHATWG Fetch API.
Loading...
Searching...
No Matches
File Streaming Support

Support for streaming files with user-controlled completion. More...

Typedefs

typedef fetch_stream_result_t(* fetch_file_continue_cb) (void *userdata)
 Callback function for controlling file streaming continuation.
 

Enumerations

enum  fetch_stream_result_t { FETCH_STREAM_READ = 0 , FETCH_STREAM_DONE = 1 , FETCH_STREAM_SKIP = 2 }
 Return codes for file streaming continue callback. More...
 

Detailed Description

Support for streaming files with user-controlled completion.

Typedef Documentation

◆ fetch_file_continue_cb

typedef fetch_stream_result_t(* fetch_file_continue_cb) (void *userdata)

Callback function for controlling file streaming continuation.

This callback is called when the library needs to determine if there's more data to read from a streaming file. Use this for files of unknown length like continuously written logs or live streams.

The callback should return:

  • FETCH_STREAM_READ: More data is available, continue reading
  • FETCH_STREAM_DONE: No more data will be available, finalize the stream
  • FETCH_STREAM_SKIP: No data currently available, but more may come later
Parameters
userdataUser-provided data passed to fetch_body_file()
Returns
fetch_stream_result_t indicating the stream state
Note
This callback enables chunked transfer encoding automatically
The callback may be called multiple times during the upload
// Example: Streaming a log file that's being written to
fetch_stream_result_t continue_log_stream(void *userdata) {
LogStreamContext *ctx = (LogStreamContext*)userdata;
if (ctx->should_stop) {
}
// Check if new data has been written to the file
if (has_new_log_data(ctx)) {
}
return FETCH_STREAM_SKIP; // No new data yet, but keep trying
}
fetch_stream_result_t
Return codes for file streaming continue callback.
Definition fetch.h:73
@ FETCH_STREAM_DONE
Definition fetch.h:75
@ FETCH_STREAM_SKIP
Definition fetch.h:76
@ FETCH_STREAM_READ
Definition fetch.h:74

Enumeration Type Documentation

◆ fetch_stream_result_t

Return codes for file streaming continue callback.

Enumerator
FETCH_STREAM_READ 

More data available to read

FETCH_STREAM_DONE 

No more data, end stream

FETCH_STREAM_SKIP 

No data currently, but not done