MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / process_request

Method process_request

src/server/connection.cpp:73–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void Connection::process_request()
74{
75 response_ = {};
76 response_.version(request_.version());
77
78 boost::asio::ip::address remote_address;
79 boost::beast::error_code endpoint_ec;
80 const auto endpoint = stream_.socket().remote_endpoint(endpoint_ec);
81 if (!endpoint_ec)
82 {
83 remote_address = endpoint.address();
84 }
85
86 try
87 {
88 request_handler_.HandleRequest(request_, response_, remote_address);
89 }
90 catch (const std::exception &e)
91 {
92 util::Log(logERROR) << "Request processing error: " << e.what();
93 SetInternalServerError(response_);
94 }
95
96 const bool keep_alive = should_keep_alive();
97 response_.keep_alive(keep_alive);
98
99 if (keep_alive)
100 {
101 response_.set(bhttp::field::connection, "keep-alive");
102 response_.set("Keep-Alive",
103 std::format("timeout={}, max={}",
104 keepalive_timeout_,
105 KEEPALIVE_MAX_REQUESTS - processed_requests_));
106 }
107 else
108 {
109 response_.set(bhttp::field::connection, "close");
110 }
111
112 const auto compression = determine_compression();
113 if (compression != http::no_compression && !response_.body().empty())
114 {
115 auto compressed = compress_buffers(response_.body(), compression);
116 response_.body() = std::move(compressed);
117
118 if (compression == http::gzip_rfc1952)
119 {
120 response_.set(bhttp::field::content_encoding, "gzip");
121 }
122 else if (compression == http::deflate_rfc1951)
123 {
124 response_.set(bhttp::field::content_encoding, "deflate");
125 }
126
127 response_.set(bhttp::field::vary, "Accept-Encoding");
128 }
129
130 response_.prepare_payload();

Callers 1

handle_readMethod · 0.95

Calls 7

LogClass · 0.85
SetInternalServerErrorFunction · 0.85
formatFunction · 0.85
whatMethod · 0.80
setMethod · 0.80
HandleRequestMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected