MCPcopy Create free account
hub / github.com/apache/brpc / UpdateResponseHeader

Function UpdateResponseHeader

src/brpc/controller.cpp:430–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430inline 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
450void Controller::SetFailed(const std::string& reason) {
451 _error_code = -1;

Callers 2

SetFailedMethod · 0.85
CloseConnectionMethod · 0.85

Calls 9

ErrorCodeToStatusCodeFunction · 0.85
request_protocolMethod · 0.80
ErrorCodeMethod · 0.80
set_status_codeMethod · 0.80
ErrorTextMethod · 0.80
FailedMethod · 0.45
serverMethod · 0.45
clearMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected