MCPcopy Create free account
hub / github.com/3rdparty/libprocess / stream

Function stream

src/http.cpp:1656–1694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1654
1655
1656Future<Nothing> stream(
1657 const network::Socket& socket,
1658 http::Pipe::Reader reader)
1659{
1660 return loop(
1661 None(),
1662 [=]() mutable {
1663 return reader.read();
1664 },
1665 [=](const string& data) mutable {
1666 bool finished = false;
1667
1668 ostringstream out;
1669
1670 if (data.empty()) {
1671 // Finished reading.
1672 out << "0\r\n" << "\r\n";
1673 finished = true;
1674 } else {
1675 out << std::hex << data.size() << "\r\n";
1676 out << data;
1677 out << "\r\n";
1678 }
1679
1680 Encoder* encoder = new DataEncoder(out.str());
1681
1682 return send(socket, encoder)
1683 .onAny([=]() {
1684 delete encoder;
1685 })
1686 .then([=]() mutable -> ControlFlow<Nothing> {
1687 if (!finished) {
1688 return Continue();
1689 }
1690
1691 return Break();
1692 });
1693 });
1694}
1695
1696
1697Future<Nothing> stream(

Callers 1

sendFunction · 0.85

Calls 11

loopFunction · 0.85
InternalServerErrorClass · 0.85
sendFunction · 0.70
ContinueClass · 0.50
BreakFunction · 0.50
readMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
thenMethod · 0.45
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected