| 556 | } |
| 557 | |
| 558 | void Server::SendHttpBadRequest(struct mg_connection* const connection, |
| 559 | const struct mg_request_info* request_info, |
| 560 | const std::string& body) { |
| 561 | LOG(TRACE) << "Entering Server::SendHttpBadRequest"; |
| 562 | |
| 563 | std::string body_to_send = body + "\r\n"; |
| 564 | |
| 565 | std::ostringstream out; |
| 566 | out << "HTTP/1.1 400 Bad Request\r\n" |
| 567 | << "Content-Length: " << strlen(body_to_send.c_str()) << "\r\n" |
| 568 | << "Content-Type: application/json; charset=utf-8\r\n" |
| 569 | << "Cache-Control: no-cache\r\n" |
| 570 | << "Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept\r\n" |
| 571 | << "Accept-Ranges: bytes\r\n\r\n"; |
| 572 | if (strcmp(request_info->request_method, "HEAD") != 0) { |
| 573 | out << body_to_send; |
| 574 | } |
| 575 | |
| 576 | mg_printf(connection, "%s", out.str().c_str()); |
| 577 | } |
| 578 | |
| 579 | void Server::SendHttpInternalError(struct mg_connection* connection, |
| 580 | const struct mg_request_info* request_info, |
no test coverage detected