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

Function MakeFullRequestImpl

library/cpp/neh/http_common.cpp:167–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165
166 template <typename T>
167 bool MakeFullRequestImpl(TMessage& msg, const TStringBuf proxy, const T& urlParams, const TStringBuf headers, const TStringBuf content, const TStringBuf contentType, ERequestType reqType, ERequestFlags reqFlags) {
168 NNeh::TParsedLocation loc(msg.Addr);
169
170 if (content.size()) {
171 //content MUST be placed inside POST requests
172 if (!IsEmpty(urlParams)) {
173 if (NeedGetRequestFor(loc.Scheme)) {
174 msg.Data = BuildRequest(loc, urlParams, headers, content, contentType, ChooseReqType(reqType, ERequestType::Post), reqFlags);
175 } else {
176 // cannot place in first header line potentially unsafe data from POST message
177 // (can contain forbidden for url-path characters)
178 // so support such mutation only for GET requests
179 return false;
180 }
181 } else {
182 if (NeedGetRequestFor(loc.Scheme) || NeedPostRequestFor(loc.Scheme)) {
183 msg.Data = BuildRequest(loc, urlParams, headers, content, contentType, ChooseReqType(reqType, ERequestType::Post), reqFlags);
184 } else {
185 return false;
186 }
187 }
188 } else {
189 if (NeedGetRequestFor(loc.Scheme)) {
190 msg.Data = BuildRequest(loc, urlParams, headers, "", "", ChooseReqType(reqType, ERequestType::Get), reqFlags);
191 } else if (NeedPostRequestFor(loc.Scheme)) {
192 msg.Data = BuildRequest(loc, TString(), headers, urlParams, contentType, ChooseReqType(reqType, ERequestType::Post), reqFlags);
193 } else {
194 return false;
195 }
196 }
197
198 if (proxy.IsInited()) {
199 loc = NNeh::TParsedLocation(proxy);
200 msg.Addr = proxy;
201 }
202
203 TString schemePostfix = "";
204 if (loc.Scheme.EndsWith("+unix")) {
205 schemePostfix = "+unix";
206 }
207
208 // ugly but still... https2 will break it :(
209 if ('s' == loc.Scheme[loc.Scheme.size() - 1]) {
210 msg.Addr.replace(0, loc.Scheme.size(), schemeFulls + schemePostfix);
211 } else {
212 msg.Addr.replace(0, loc.Scheme.size(), schemeFull + schemePostfix);
213 }
214
215 return true;
216 }
217
218 bool MakeFullRequest(TMessage& msg, const TStringBuf headers, const TStringBuf content, const TStringBuf contentType, ERequestType reqType, ERequestFlags reqFlags) {
219 return MakeFullRequestImpl(msg, {}, msg.Data, headers, content, contentType, reqType, reqFlags);

Callers 2

MakeFullRequestFunction · 0.85
MakeFullProxyRequestFunction · 0.85

Calls 10

NeedGetRequestForFunction · 0.85
BuildRequestFunction · 0.85
ChooseReqTypeFunction · 0.85
NeedPostRequestForFunction · 0.85
IsInitedMethod · 0.80
IsEmptyFunction · 0.70
TParsedLocationClass · 0.70
sizeMethod · 0.45
EndsWithMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected