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

Method readMultipart

base/poco/Net/src/HTMLForm.cpp:341–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339
340
341void HTMLForm::readMultipart(std::istream& istr, PartHandler& handler)
342{
343 static const int eof = std::char_traits<char>::eof();
344
345 int fields = 0;
346 MultipartReader reader(istr, _boundary);
347 while (reader.hasNextPart())
348 {
349 if (_fieldLimit > 0 && fields == _fieldLimit)
350 throw HTMLFormException("Too many form fields");
351 MessageHeader header;
352 reader.nextPart(header);
353 std::string disp;
354 NameValueCollection params;
355 if (header.has("Content-Disposition"))
356 {
357 std::string cd = header.get("Content-Disposition");
358 MessageHeader::splitParameters(cd, disp, params);
359 }
360 if (params.has("filename"))
361 {
362 handler.handlePart(header, reader.stream());
363 // Ensure that the complete part has been read.
364 while (reader.stream().good()) reader.stream().get();
365 }
366 else
367 {
368 std::string name = params["name"];
369 std::string value;
370 std::istream& istr = reader.stream();
371 int ch = istr.get();
372 while (ch != eof)
373 {
374 if (value.size() < _valueLengthLimit)
375 value += (char) ch;
376 else
377 throw HTMLFormException("Field value too long");
378 ch = istr.get();
379 }
380 add(name, value);
381 }
382 ++fields;
383 }
384}
385
386
387void HTMLForm::writeUrl(std::ostream& ostr)

Callers

nothing calls this directly

Calls 9

hasNextPartMethod · 0.80
addFunction · 0.50
nextPartMethod · 0.45
hasMethod · 0.45
getMethod · 0.45
handlePartMethod · 0.45
streamMethod · 0.45
goodMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected