+ size_t bytes_before_suitable_starting_point;
+ if (last_suitable_starting_point == -1) {
+ bytes_before_suitable_starting_point = existing_data.size();
+ } else if (size_t(last_suitable_starting_point) < backlog_size) {
+ bytes_before_suitable_starting_point = 0;
+ } else {
+ bytes_before_suitable_starting_point = last_suitable_starting_point - backlog_size;
+ }
+
+ vector<DataElement> data_elements;
+ if (bytes_before_suitable_starting_point > 0) {
+ // There's really no usable data here (except for ?backlog=1 users),
+ // but we need to get the accounting right anyway.
+ DataElement data_element;
+ data_element.data.iov_base = const_cast<char *>(existing_data.data());
+ data_element.data.iov_len = bytes_before_suitable_starting_point;
+ data_element.suitable_for_stream_start = NOT_SUITABLE_FOR_STREAM_START;
+ data_elements.push_back(data_element);
+ }
+ if (bytes_before_suitable_starting_point < existing_data.size()) {
+ DataElement data_element;
+ data_element.data.iov_base = const_cast<char *>(existing_data.data() + bytes_before_suitable_starting_point);
+ data_element.data.iov_len = existing_data.size() - bytes_before_suitable_starting_point;
+ data_element.suitable_for_stream_start = SUITABLE_FOR_STREAM_START;
+ data_elements.push_back(data_element);
+ }
+
+ last_suitable_starting_point = -1;
+ add_data_raw(data_elements);