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

Method OutTo

library/cpp/http/server/response.cpp:21–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21void THttpResponse::OutTo(IOutputStream& os) const {
22 TVector<IOutputStream::TPart> parts;
23 const size_t FIRST_LINE_PARTS = 3;
24 const size_t HEADERS_PARTS = Headers.Count() * 4;
25 const size_t CONTENT_PARTS = 5;
26 parts.reserve(FIRST_LINE_PARTS + HEADERS_PARTS + CONTENT_PARTS);
27
28 // first line
29 parts.push_back(IOutputStream::TPart(TStringBuf("HTTP/1.1 ")));
30 parts.push_back(IOutputStream::TPart(HttpCodeStrEx(Code)));
31 parts.push_back(IOutputStream::TPart::CrLf());
32
33 // headers
34 for (THttpHeaders::TConstIterator i = Headers.Begin(); i != Headers.End(); ++i) {
35 parts.push_back(IOutputStream::TPart(i->Name()));
36 parts.push_back(IOutputStream::TPart(TStringBuf(": ")));
37 parts.push_back(IOutputStream::TPart(i->Value()));
38 parts.push_back(IOutputStream::TPart::CrLf());
39 }
40
41 char buf[50];
42
43 if (!Content.empty()) {
44 TMemoryOutput mo(buf, sizeof(buf));
45
46 mo << Content.size();
47
48 parts.push_back(IOutputStream::TPart(TStringBuf("Content-Length: ")));
49 parts.push_back(IOutputStream::TPart(buf, mo.Buf() - buf));
50 parts.push_back(IOutputStream::TPart::CrLf());
51 }
52
53 // content
54 parts.push_back(IOutputStream::TPart::CrLf());
55
56 if (!Content.empty()) {
57 parts.push_back(IOutputStream::TPart(Content));
58 }
59
60 os.Write(parts.data(), parts.size());
61}
62
63template <>
64void Out<THttpResponse>(IOutputStream& os, const THttpResponse& resp) {

Callers 1

Out<THttpResponse>Function · 0.45

Calls 14

TPartClass · 0.85
HttpCodeStrExFunction · 0.85
CountMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45
NameMethod · 0.45
ValueMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
BufMethod · 0.45

Tested by

no test coverage detected