cpp-httplib icon indicating copy to clipboard operation
cpp-httplib copied to clipboard

ContentReceiver chunk size cannot greater than 4096

Open Huweicai opened this issue 1 year ago • 0 comments

I am using cpp-httplib to watch server side events, instead of downloading some big files.

The interface looks like below while using curl pic

My code looks like below:

auto res = cli.Get("/events,watch=true", [&](const char *data, size_t data_length) -> bool {
        auto event = json_parse(data, data_length);
        handle_event(event);
        return true;
    });

Each chunk stands for an event, but sometimes the event may be bigger than 4096, then it will be cut down, and json parse will fail.

I've seen the issue https://github.com/yhirose/cpp-httplib/issues/1191, avoid to regard the data as a whole piece, but it's hard for me to distinguish the boundary of each event to put it together.

Do you have any good idea on it?

  • add another flag to indicate the chunk finished
  • increase the read buffer size

Huweicai avatar Jun 06 '24 04:06 Huweicai