libfetch 0.0.0
A lightweight asynchronous HTTP/1.1 client library implementing a subset of the WHATWG Fetch API.
Loading...
Searching...
No Matches
fetch_body_t Struct Reference

Request or response body. More...

#include <fetch.h>

Data Fields

fetch_body_type_t type
 
union { 
 
   struct { 
 
      const void *   data 
 
      size_t   size 
 
   }   memory 
 
   struct { 
 
      FETCH_FILE_HANDLE   handle 
 
      size_t   size 
 
      size_t   offset 
 
      bool   close_on_free 
 
      fetch_file_continue_cb   continue_cb 
 
      void *   userdata 
 
   }   file 
 
data 
 
const char * content_type
 

Detailed Description

Request or response body.

Contains the data payload along with its type and content type. Supports both in-memory data and file streaming using a tagged union.

For file streaming, the library supports:

  • Regular files: Known size, uses Content-Length header
  • Streaming files: Unknown/dynamic size, uses chunked transfer encoding
  • Live streams: Continuous data with user-controlled completion via callback
Note
Memory: Caller owns the body and must call fetch_body_free()

Field Documentation

◆ close_on_free

bool fetch_body_t::close_on_free

Whether to close handle when body is freed

◆ content_type

const char* fetch_body_t::content_type

MIME content type

◆ continue_cb

fetch_file_continue_cb fetch_body_t::continue_cb

NULL = regular file, non-NULL = streaming

◆ data [1/2]

const void* fetch_body_t::data

Pointer to body data

◆ [union] [2/2]

union { ... } fetch_body_t::data

◆ [struct]

struct { ... } fetch_body_t::file

◆ handle

FETCH_FILE_HANDLE fetch_body_t::handle

File handle for streaming

◆ [struct]

struct { ... } fetch_body_t::memory

◆ offset

size_t fetch_body_t::offset

Current read offset in file

◆ size

size_t fetch_body_t::size

Size of body in bytes

File size in bytes (0 if unknown)

◆ type

fetch_body_type_t fetch_body_t::type

Type of body content (union tag)

◆ userdata

void* fetch_body_t::userdata

User data for callback


The documentation for this struct was generated from the following file: