MCPcopy Create free account
hub / github.com/catboost/catboost / Send

Method Send

library/cpp/neh/http2.cpp:1626–1678  ·  view source on GitHub ↗

called non thread-safe (from outside thread)

Source from the content-addressed store, hash-verified

1624 public:
1625 //called non thread-safe (from outside thread)
1626 void Send(TAtomicBase requestId, TData& data, const TString& compressionScheme, const THttpVersion& ver, const TString& headers, int httpCode) {
1627 class THttpResponseFormatter {
1628 public:
1629 THttpResponseFormatter(TData& theData, const TString& contentEncoding, const THttpVersion& theVer, const TString& theHeaders, int theHttpCode, bool closeConnection) {
1630 Header.Reserve(128 + contentEncoding.size() + theHeaders.size());
1631 PrintHttpVersion(Header, theVer);
1632 Header << TStringBuf(" ") << theHttpCode << ' ' << HttpCodeStr(theHttpCode);
1633 if (Compress(theData, contentEncoding)) {
1634 Header << TStringBuf("\r\nContent-Encoding: ") << contentEncoding;
1635 }
1636 Header << TStringBuf("\r\nContent-Length: ") << theData.size();
1637 if (closeConnection) {
1638 Header << TStringBuf("\r\nConnection: close");
1639 } else if (Y_LIKELY(theVer.Major > 1 || theVer.Minor > 0)) {
1640 // since HTTP/1.1 Keep-Alive is default behaviour
1641 Header << TStringBuf("\r\nConnection: Keep-Alive");
1642 }
1643 if (theHeaders) {
1644 Header << theHeaders;
1645 }
1646 Header << TStringBuf("\r\n\r\n");
1647
1648 Body.swap(theData);
1649
1650 Parts[0].buf = Header.Data();
1651 Parts[0].len = Header.Size();
1652 Parts[1].buf = Body.data();
1653 Parts[1].len = Body.size();
1654 }
1655
1656 TStringStream Header;
1657 TData Body;
1658 IOutputStream::TPart Parts[2];
1659 };
1660
1661 class TBuffers: public THttpResponseFormatter, public TTcpSocket::IBuffers {
1662 public:
1663 TBuffers(TData& theData, const TString& contentEncoding, const THttpVersion& theVer, const TString& theHeaders, int theHttpCode, bool closeConnection)
1664 : THttpResponseFormatter(theData, contentEncoding, theVer, theHeaders, theHttpCode, closeConnection)
1665 , IOVec(Parts, 2)
1666 {
1667 }
1668
1669 TContIOVector* GetIOvec() override {
1670 return &IOVec;
1671 }
1672
1673 TContIOVector IOVec;
1674 };
1675
1676 TTcpSocket::TSendedData sd(new TBuffers(data, compressionScheme, ver, headers, httpCode, SeenMessageWithoutKeepalive_));
1677 SendData(requestId, sd);
1678 }
1679
1680 //called non thread-safe (from outside thread)
1681 void SendError(TAtomicBase requestId, unsigned httpCode, const TString& descr, const THttpVersion& ver, const TString& headers) {

Callers 4

SendReplyMethod · 0.45
Y_UNIT_TESTFunction · 0.45
SendWithHighPriorityMethod · 0.45
DoSendsMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected