| 485 | |
| 486 | bool HttpIncomingMessage::pushBodyData(AsyncBufferView::ID bufferID, size_t sizeInBytes) |
| 487 | { |
| 488 | return bodyStream.pushBodyData(bufferID, sizeInBytes); |
| 489 | } |
| 490 | |
| 491 | void HttpIncomingMessage::finishBodyStream() |
| 492 | { |
| 493 | bodyComplete = true; |
| 494 | bodyStream.finishBody(); |
| 495 | } |
| 496 | |
| 497 | void HttpIncomingMessage::failBodyStream(Result result) |
| 498 | { |
| 499 | bodyComplete = false; |
| 500 | bodyStream.failBody(result); |
| 501 | } |
| 502 | |
| 503 | void HttpIncomingMessage::abortBodyStream() { bodyStream.destroy(); } |
| 504 | |
| 505 | Result HttpIncomingMessage::prepareBodyStream(AsyncBuffersPool& buffersPool, Function<Result()>&& onReadRequest, |
| 506 | bool allowCloseDelimited) |
| 507 | { |
| 508 | StringSpan transferEncoding; |
| 509 | StringSpan contentLengthValue; |
| 510 | const bool hasTransferEncoding = getHeader("Transfer-Encoding", transferEncoding); |
| 511 | if (hasTransferEncoding and getHeader("Content-Length", contentLengthValue)) |
| 512 | { |
| 513 | return Result::Error(HttpResultCategory, HttpError::BodyFramingHeadersConflict); |
| 514 | } |
| 515 | |
| 516 | if (hasTransferEncoding) |
| 517 | { |
| 518 | if (not scHttpTransferEncodingIsChunked(transferEncoding)) |
| 519 | { |
| 520 | return Result::Error(HttpResultCategory, HttpError::TransferEncodingUnsupported); |
| 521 | } |
| 522 | bodyFramingKind = HttpBodyFramingKind::Chunked; |
| 523 | bodyBytesRemaining = 0; |
| 524 | bodyComplete = false; |
| 525 | chunkedState = ChunkedState::Size; |
| 526 | chunkedChunkSize = 0; |
| 527 | chunkedBytesRemaining = 0; |
| 528 | chunkedSizeHasDigits = false; |
| 529 | } |
| 530 | else if (getHeader("Content-Length", contentLengthValue)) |
| 531 | { |
| 532 | bodyFramingKind = HttpBodyFramingKind::ContentLength; |
| 533 | bodyBytesRemaining = getParser().contentLength; |
| 534 | bodyComplete = (bodyBytesRemaining == 0); |
| 535 | } |
no test coverage detected