| 296 | } |
| 297 | |
| 298 | bool HTMLForm::MultipartReadBuffer::nextImpl() |
| 299 | { |
| 300 | if (boundary_hit) |
| 301 | return false; |
| 302 | |
| 303 | assert(position() >= in.position()); |
| 304 | |
| 305 | in.position() = position(); |
| 306 | |
| 307 | /// We expect to start from the first symbol after EOL, so we can put checkpoint |
| 308 | /// and safely try to read til the next EOL and check for boundary. |
| 309 | in.setCheckpoint(); |
| 310 | |
| 311 | /// FIXME: there is an extra copy because we cannot traverse PeekableBuffer from checkpoint to position() |
| 312 | /// since it may store different data parts in different sub-buffers, |
| 313 | /// anyway calling makeContinuousMemoryFromCheckpointToPos() will also make an extra copy. |
| 314 | /// According to RFC2046 the preceding CRLF is a part of boundary line. |
| 315 | std::string line = readLine(false); |
| 316 | boundary_hit = startsWith(line, "\r\n" + boundary); |
| 317 | bool has_next = !boundary_hit && !line.empty(); |
| 318 | |
| 319 | if (has_next) |
| 320 | /// If we don't make sure that memory is contiguous then situation may happen, when part of the line is inside internal memory |
| 321 | /// and other part is inside sub-buffer, thus we'll be unable to setup our working buffer properly. |
| 322 | in.makeContinuousMemoryFromCheckpointToPos(); |
| 323 | |
| 324 | in.rollbackToCheckpoint(true); |
| 325 | |
| 326 | /// Rolling back to checkpoint may change underlying buffers. |
| 327 | /// Limit readable data to a single line. |
| 328 | BufferBase::set(in.position(), line.size(), 0); |
| 329 | |
| 330 | return has_next; |
| 331 | } |
| 332 | |
| 333 | } |
nothing calls this directly
no test coverage detected