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

Method RebuildStream

library/cpp/http/io/stream.cpp:805–840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

803 }
804
805 inline void RebuildStream() {
806 bool keepAlive = false;
807 const TCompressionCodecFactory::TEncoderConstructor* encoder = nullptr;
808 bool chunked = false;
809 bool haveContentLength = false;
810
811 for (THttpHeaders::TConstIterator h = Headers_.Begin(); h != Headers_.End(); ++h) {
812 const THttpInputHeader& header = *h;
813 const TString hl = to_lower(header.Name());
814
815 if (hl == TStringBuf("connection")) {
816 keepAlive = to_lower(header.Value()) == TStringBuf("keep-alive");
817 } else if (IsCompressionHeaderEnabled() && hl == TStringBuf("content-encoding")) {
818 encoder = TCompressionCodecFactory::Instance().FindEncoder(to_lower(header.Value()));
819 } else if (hl == TStringBuf("transfer-encoding")) {
820 chunked = to_lower(header.Value()) == TStringBuf("chunked");
821 } else if (hl == TStringBuf("content-length")) {
822 haveContentLength = true;
823 }
824 }
825
826 if (!haveContentLength && !chunked && (IsHttpRequest() || HasResponseBody()) && SupportChunkedTransfer() && (keepAlive || encoder || IsHttpRequest())) {
827 AddHeader(THttpInputHeader("Transfer-Encoding", "chunked"));
828 chunked = true;
829 }
830
831 if (IsBodyEncodingEnabled() && chunked) {
832 Output_ = Streams_.Add(new TChunkedOutput(Output_));
833 }
834
835 Output_ = Streams_.Add(new TTeeOutput(Output_, &SizeCalculator_));
836
837 if (IsBodyEncodingEnabled() && encoder) {
838 Output_ = Streams_.Add((*encoder)(Output_).Release());
839 }
840 }
841
842 inline void AddHeader(const THttpInputHeader& hdr) {
843 Headers_.AddHeader(hdr);

Callers

nothing calls this directly

Calls 10

to_lowerFunction · 0.85
InstanceFunction · 0.85
THttpInputHeaderClass · 0.85
FindEncoderMethod · 0.80
BeginMethod · 0.45
EndMethod · 0.45
NameMethod · 0.45
ValueMethod · 0.45
AddMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected