MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / nextImpl

Method nextImpl

src/Server/HTTP/HTMLForm.cpp:320–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320bool HTMLForm::MultipartReadBuffer::nextImpl()
321{
322 if (boundary_hit)
323 return false;
324
325 chassert(position() >= in.position());
326
327 in.position() = position();
328
329 /// We expect to start from the first symbol after EOL, so we can put checkpoint
330 /// and safely try to read til the next EOL and check for boundary.
331 in.setCheckpoint();
332
333 /// FIXME: there is an extra copy because we cannot traverse PeekableBuffer from checkpoint to position()
334 /// since it may store different data parts in different sub-buffers,
335 /// anyway calling makeContinuousMemoryFromCheckpointToPos() will also make an extra copy.
336 /// According to RFC2046 the preceding CRLF is a part of boundary line.
337 std::string line = readLine(false);
338 boundary_hit = startsWith(line, "\r\n" + boundary);
339 bool has_next = !boundary_hit && !line.empty();
340
341 if (has_next)
342 /// If we don't make sure that memory is contiguous then situation may happen, when part of the line is inside internal memory
343 /// and other part is inside sub-buffer, thus we'll be unable to setup our working buffer properly.
344 in.makeContinuousMemoryFromCheckpointToPos();
345
346 in.rollbackToCheckpoint(true);
347
348 /// Rolling back to checkpoint may change underlying buffers.
349 /// Limit readable data to a single line.
350 BufferBase::set(in.position(), line.size(), 0);
351
352 return has_next;
353}
354
355}

Callers

nothing calls this directly

Calls 10

positionClass · 0.85
readLineFunction · 0.85
startsWithFunction · 0.50
setFunction · 0.50
positionMethod · 0.45
setCheckpointMethod · 0.45
emptyMethod · 0.45
rollbackToCheckpointMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected