| 898 | Result writeResult = connection->getWritableTransportStream().write( |
| 899 | AsyncBufferView(currentRequest->getBodySpan()), |
| 900 | {[this](AsyncBufferView::ID) { connection->getWritableTransportStream().end(); }}); |
| 901 | if (not writeResult) |
| 902 | { |
| 903 | fail(writeResult); |
| 904 | } |
| 905 | } |
| 906 | else if (currentRequest->getBodyType() == HttpAsyncClientRequest::BodyType::Multipart) |
| 907 | { |
| 908 | static constexpr const char* HeaderSpaceFinished = "HttpAsyncClient header space is finished"; |
| 909 | |
| 910 | const HttpMultipartWriter& writer = *currentRequest->getMultipartWriter(); |
| 911 | HttpFixedBufferWriter bodyWriter; |
| 912 | bodyWriter.reset(connection->getHeaderMemory()); |
| 913 | const auto appendMultipartBody = [&]() -> Result |
| 914 | { |
| 915 | for (size_t idx = 0; idx < writer.getNumParts(); ++idx) |
| 916 | { |
| 917 | const HttpMultipartWriter::Part& part = writer.getPart(idx); |
| 918 | SC_TRY(bodyWriter.appendLiteral("--", HeaderSpaceFinished)); |
| 919 | SC_TRY(bodyWriter.append(writer.getBoundary(), HeaderSpaceFinished)); |
| 920 | SC_TRY(bodyWriter.appendLiteral("\r\nContent-Disposition: form-data; name=\"", HeaderSpaceFinished)); |
| 921 | SC_TRY(bodyWriter.append(part.partName, HeaderSpaceFinished)); |
| 922 | SC_TRY(bodyWriter.appendLiteral("\"", HeaderSpaceFinished)); |
| 923 | if (part.fileName.sizeInBytes() > 0) |
| 924 | { |
| 925 | SC_TRY(bodyWriter.appendLiteral("; filename=\"", HeaderSpaceFinished)); |
| 926 | SC_TRY(bodyWriter.append(part.fileName, HeaderSpaceFinished)); |
| 927 | SC_TRY(bodyWriter.appendLiteral("\"", HeaderSpaceFinished)); |
| 928 | } |
| 929 | SC_TRY(bodyWriter.appendLiteral("\r\n", HeaderSpaceFinished)); |
| 930 | if (part.contentType.sizeInBytes() > 0) |
| 931 | { |
| 932 | SC_TRY(bodyWriter.appendLiteral("Content-Type: ", HeaderSpaceFinished)); |
| 933 | SC_TRY(bodyWriter.append(part.contentType, HeaderSpaceFinished)); |
nothing calls this directly
no test coverage detected