MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / SendHttpOk

Method SendHttpOk

cpp/webdriver-server/server.cc:536–556  ·  view source on GitHub ↗

The standard HTTP Status codes are implemented below. Chrome uses OK, See Other, Not Found, Method Not Allowed, and Internal Error. Internal Error, HTTP 500, is used as a catch all for any issue not covered in the JSON protocol.

Source from the content-addressed store, hash-verified

534// Internal Error, HTTP 500, is used as a catch all for any issue
535// not covered in the JSON protocol.
536void Server::SendHttpOk(struct mg_connection* connection,
537 const struct mg_request_info* request_info,
538 const std::string& body,
539 const std::string& content_type) {
540 LOG(TRACE) << "Entering Server::SendHttpOk";
541
542 std::string body_to_send = body + "\r\n";
543
544 std::ostringstream out;
545 out << "HTTP/1.1 200 OK\r\n"
546 << "Content-Length: " << strlen(body_to_send.c_str()) << "\r\n"
547 << "Content-Type: " << content_type << "; charset=utf-8\r\n"
548 << "Cache-Control: no-cache\r\n"
549 << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n"
550 << "Accept-Ranges: bytes\r\n\r\n";
551 if (strcmp(request_info->request_method, "HEAD") != 0) {
552 out << body_to_send;
553 }
554
555 mg_write(connection, out.str().c_str(), out.str().size());
556}
557
558void Server::SendHttpBadRequest(struct mg_connection* const connection,
559 const struct mg_request_info* request_info,

Callers 2

ProcessRequestMethod · 0.95
SendResponseToClientMethod · 0.95

Calls 2

LOGClass · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected