drogonframework/drogon

Passing binary arrays directly to a resp->setBody()

Open

#2.139 geöffnet am 24. Aug. 2024

Auf GitHub ansehen
 (5 Kommentare) (1 Reaktion) (0 zugewiesene Personen)C++ (1.014 Forks)batch import
enhancementgood first issue

Repository-Metriken

Stars
 (10.462 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 2T 2h) (7 gemergte PRs in 30 T)

Beschreibung

It's disheartening to dance on eggshells when trying to pass a large binary array to drogon's setBody method. Nothing works. No shared_ptr, no string_view, nothing. The only way to pass a binary array right now seems to be using the list constructor of std::string by calling std::string fullResponse(char* myData, size_t myDataSize); and then calling std::move to hand it over to the setBody method, which involves a wholly unnecessary copy operation. Yes, compared to the compression, serialization, its not really THAT relevant. Nonetheless, what I would like is a method overload which accepts a char* and a size_t. The same goes for the send() method of the async stream.

Contributor Guide