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