MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / process_request

Method process_request

external/httplib.h:7016–7192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7014}
7015
7016inline bool
7017Server::process_request(Stream &strm, const std::string &remote_addr,
7018 int remote_port, const std::string &local_addr,
7019 int local_port, bool close_connection,
7020 bool &connection_closed,
7021 const std::function<void(Request &)> &setup_request) {
7022 std::array<char, 2048> buf{};
7023
7024 detail::stream_line_reader line_reader(strm, buf.data(), buf.size());
7025
7026 // Connection has been closed on client
7027 if (!line_reader.getline()) { return false; }
7028
7029 Request req;
7030
7031 Response res;
7032 res.version = "HTTP/1.1";
7033 res.headers = default_headers_;
7034
7035#ifdef _WIN32
7036 // TODO: Increase FD_SETSIZE statically (libzmq), dynamically (MySQL).
7037#else
7038#ifndef CPPHTTPLIB_USE_POLL
7039 // Socket file descriptor exceeded FD_SETSIZE...
7040 if (strm.socket() >= FD_SETSIZE) {
7041 Headers dummy;
7042 detail::read_headers(strm, dummy);
7043 res.status = StatusCode::InternalServerError_500;
7044 return write_response(strm, close_connection, req, res);
7045 }
7046#endif
7047#endif
7048
7049 // Check if the request URI doesn't exceed the limit
7050 if (line_reader.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) {
7051 Headers dummy;
7052 detail::read_headers(strm, dummy);
7053 res.status = StatusCode::UriTooLong_414;
7054 return write_response(strm, close_connection, req, res);
7055 }
7056
7057 // Request line and headers
7058 if (!parse_request_line(line_reader.ptr(), req) ||
7059 !detail::read_headers(strm, req.headers)) {
7060 res.status = StatusCode::BadRequest_400;
7061 return write_response(strm, close_connection, req, res);
7062 }
7063
7064 if (req.get_header_value("Connection") == "close") {
7065 connection_closed = true;
7066 }
7067
7068 if (req.version == "HTTP/1.0" &&
7069 req.get_header_value("Connection") != "Keep-Alive") {
7070 connection_closed = true;
7071 }
7072
7073 req.remote_addr = remote_addr;

Callers

nothing calls this directly

Calls 15

read_headersFunction · 0.85
to_stringFunction · 0.85
parse_range_headerFunction · 0.85
write_response_lineFunction · 0.85
range_errorFunction · 0.85
find_content_typeFunction · 0.85
read_contentFunction · 0.85
dataMethod · 0.80
getlineMethod · 0.80
socketMethod · 0.80
ptrMethod · 0.80
get_header_valueMethod · 0.80

Tested by

no test coverage detected