MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / processBodyData

Method processBodyData

Libraries/Http/HttpConnection.cpp:534–730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

532 bodyFramingKind = HttpBodyFramingKind::ContentLength;
533 bodyBytesRemaining = getParser().contentLength;
534 bodyComplete = (bodyBytesRemaining == 0);
535 }
536 else if (allowCloseDelimited)
537 {
538 bodyFramingKind = HttpBodyFramingKind::CloseDelimited;
539 bodyBytesRemaining = 0;
540 bodyComplete = false;
541 }
542 else
543 {
544 bodyFramingKind = HttpBodyFramingKind::None;
545 bodyBytesRemaining = 0;
546 bodyComplete = true;
547 }
548
549 return initBodyStream(buffersPool, move(onReadRequest));
550}
551
552Result HttpIncomingMessage::processBodyData(AsyncReadableStream& sourceStream, AsyncBufferView::ID bufferID,
553 Span<const char> readData, bool allowTrailingData)
554{
555 if (bodyFramingKind == HttpBodyFramingKind::None)
556 {
557 if (readData.sizeInBytes() > 0)
558 {
559 return Result::Error(HttpResultCategory, HttpError::UnexpectedBodyData);
560 }
561 return Result(true);
562 }
563
564 if (bodyFramingKind == HttpBodyFramingKind::ContentLength or bodyFramingKind == HttpBodyFramingKind::CloseDelimited)
565 {
566 if (bodyFramingKind == HttpBodyFramingKind::ContentLength and readData.sizeInBytes() > bodyBytesRemaining)
567 {
568 return Result::Error(HttpResultCategory, HttpError::BodyExceedsContentLength);
569 }
570
571 const uint64_t remainingBeforePush = bodyBytesRemaining;
572 const bool shouldContinue = pushBodyData(bufferID, readData.sizeInBytes());
573 if (not bodyStream.hasBeenDestroyed())
574 {
575 bodyStream.reactivate(shouldContinue);
576 }
577 if (bodyFramingKind == HttpBodyFramingKind::ContentLength)
578 {
579 if (bodyBytesRemaining == remainingBeforePush)
580 {
581 SC_TRY(consumeBodyBytes(readData.sizeInBytes()));
582 }
583 else
584 {
585 if (bodyBytesRemaining + readData.sizeInBytes() != remainingBeforePush)
586 return Result::Error(HttpResultCategory, HttpError::BodyStreamConsumptionMismatch);
587 }
588 }
589 if (bodyFramingKind == HttpBodyFramingKind::ContentLength and bodyBytesRemaining == 0)
590 {
591 finishBodyStream();

Callers 3

onRequestBodyDataMethod · 0.80
onResponseDataMethod · 0.80
onResponseBodyDataMethod · 0.80

Calls 10

reactivateMethod · 0.80
pauseMethod · 0.80
unrefBufferMethod · 0.80
scHttpHexValueFunction · 0.70
ErrorEnum · 0.50
ResultClass · 0.50
sizeInBytesMethod · 0.45
dataMethod · 0.45
createChildViewMethod · 0.45
unshiftMethod · 0.45

Tested by

no test coverage detected