Stiffstream / restinio

Cross-platform, efficient, customizable, and robust asynchronous HTTP(S)/WebSocket server C++ library with the right balance between performance and ease of use
Other
1.13k stars 92 forks source link

http_header_fields_t::remove_field is not convenient for deleting all occurrences of a field #113

Closed eao197 closed 3 years ago

eao197 commented 4 years ago

There is no simple and efficient way of deleting all occurrences of a HTTP-field. Now we can do something like:

while(fields.has_field("Connection")) {
   fields.remove_field("Connection");
}

but that requires two lookups on every iteration of such while. The better way could be:

while(fields.remove_field("Connection")) {}

and that way requires that remove_field returns boolean flag (is field actually removed or not).

Another way is to add remove_all_of:

fields.remove_all_of("Connection");

and remove_all_of can return the number of deleted field occurrences.

eao197 commented 4 years ago

In 34374e78012aa4426325c7d1f46917c8e97f64f6: