Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContentReceiver chunk size cannot greater than 4096 #1845

Open
Huweicai opened this issue Jun 6, 2024 · 0 comments
Open

ContentReceiver chunk size cannot greater than 4096 #1845

Huweicai opened this issue Jun 6, 2024 · 0 comments

Comments

@Huweicai
Copy link

Huweicai commented Jun 6, 2024

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 #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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant