in proxygen/lib/http/codec/HTTP1xCodec.cpp [257:295]
void HTTP1xCodec::onParserError(const char* what) {
inRecvLastChunk_ = false;
http_errno parser_errno = HTTP_PARSER_ERRNO(&parser_);
HTTPException error(
HTTPException::Direction::INGRESS,
what ? what
: folly::to<std::string>("Error parsing message: ",
http_errno_description(parser_errno)));
// generate a string of parsed headers so that we can pass it to callback
if (msg_) {
error.setPartialMsg(std::move(msg_));
}
// store the ingress buffer
if (currentIngressBuf_) {
error.setCurrentIngressBuf(currentIngressBuf_->cloneOne());
}
if (transportDirection_ == TransportDirection::DOWNSTREAM &&
egressTxnID_ < ingressTxnID_) {
error.setHttpStatusCode(400);
} // else we've already egressed a response for this txn, don't attempt a 400
// See http_parser.h for what these error codes mean
if (parser_errno == HPE_INVALID_EOF_STATE) {
error.setProxygenError(kErrorEOF);
} else if (parser_errno == HPE_HEADER_OVERFLOW ||
parser_errno == HPE_INVALID_CONSTANT ||
(parser_errno >= HPE_INVALID_VERSION &&
parser_errno <= HPE_HUGE_CONTENT_LENGTH) ||
parser_errno == HPE_CB_header_field ||
parser_errno == HPE_CB_header_value ||
parser_errno == HPE_CB_headers_complete) {
error.setProxygenError(kErrorParseHeader);
} else if (parser_errno == HPE_INVALID_CHUNK_SIZE ||
parser_errno == HPE_HUGE_CHUNK_SIZE) {
error.setProxygenError(kErrorParseBody);
} else {
error.setProxygenError(kErrorUnknown);
}
callback_->onError(ingressTxnID_, error);
}