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

Class TRequestServer

library/cpp/neh/http_ut.cpp:24–44  ·  view source on GitHub ↗

@brief class with a method that responses to requests. */

Source from the content-addressed store, hash-verified

22 @brief class with a method that responses to requests.
23 */
24 class TRequestServer {
25 public:
26 TRequestServer(std::function<void(const IRequestRef&)> f = [](const IRequestRef& req) {
27 TDataSaver responseData;
28 Sleep(TDuration::MilliSeconds(FromString<int>(req->Data())));
29 responseData << req->Data();
30 auto* httpReq = dynamic_cast<IHttpRequest*>(req.Get());
31 TString headers = "\r\nContent-Type: text/plain";
32 httpReq->SendReply(responseData, headers);
33 })
34 : F_(f)
35 {
36 }
37
38 void ServeRequest(const IRequestRef& req) {
39 F_(req);
40 // Cerr << "SendReply:" << req->Data() << Endl;
41 }
42 private:
43 std::function<void(const IRequestRef&)> F_;
44 };
45
46 /**
47 @brief Auxiliary struct for tests with info about running services.

Callers 1

Y_UNIT_TESTFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected