| 428 | } |
| 429 | |
| 430 | inline void UpdateResponseHeader(Controller* cntl) { |
| 431 | DCHECK(cntl->Failed()); |
| 432 | if (cntl->request_protocol() == PROTOCOL_HTTP || |
| 433 | cntl->request_protocol() == PROTOCOL_H2) { |
| 434 | if (cntl->ErrorCode() != EHTTP) { |
| 435 | // Set the related status code |
| 436 | cntl->http_response().set_status_code( |
| 437 | ErrorCodeToStatusCode(cntl->ErrorCode())); |
| 438 | } // else assume that status code is already set along with EHTTP. |
| 439 | if (cntl->server() != NULL) { |
| 440 | // Override HTTP body at server-side to conduct error text |
| 441 | // to the client. |
| 442 | // The client-side should preserve body which may be a piece |
| 443 | // of useable data rather than error text. |
| 444 | cntl->response_attachment().clear(); |
| 445 | cntl->response_attachment().append(cntl->ErrorText()); |
| 446 | } |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | void Controller::SetFailed(const std::string& reason) { |
| 451 | _error_code = -1; |
no test coverage detected