Save all data from received IETF Connection Close frames
Save all data from received IETF connection close frames.
Also removes the QuicErrorCode that was prepended to the error details phrase. The phrase is the same on both the CONNECTION_CLOSE sender and receiver.
gfe-relnote: N/A rearranges existing code, new code is V99/IETF QUIC only.
PiperOrigin-RevId: 265442745
Change-Id: I1d487fc93f90863629e29b863b32c6ab9c6377e1
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index ffab835..c667e9b 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -5782,7 +5782,7 @@
// The frame may have an extracted error code in it. Look for it and
// extract it. If it's not present, MaybeExtract will return
// QUIC_IETF_GQUIC_ERROR_MISSING.
- frame->extracted_error_code = MaybeExtractQuicErrorCode(phrase);
+ MaybeExtractQuicErrorCode(frame);
return true;
}
@@ -6766,14 +6766,25 @@
// contains additional error information that narrows down the exact error. If
// the string is not found, or is not properly formed, it returns
// ErrorCode::QUIC_IETF_GQUIC_ERROR_MISSING
-QuicErrorCode MaybeExtractQuicErrorCode(QuicStringPiece error_details) {
- std::vector<QuicStringPiece> ed = QuicTextUtils::Split(error_details, ':');
+void MaybeExtractQuicErrorCode(QuicConnectionCloseFrame* frame) {
+ std::vector<QuicStringPiece> ed =
+ QuicTextUtils::Split(frame->error_details, ':');
uint64_t extracted_error_code;
if (ed.size() < 2 || !QuicTextUtils::IsAllDigits(ed[0]) ||
!QuicTextUtils::StringToUint64(ed[0], &extracted_error_code)) {
- return QUIC_IETF_GQUIC_ERROR_MISSING;
+ frame->extracted_error_code = QUIC_IETF_GQUIC_ERROR_MISSING;
+ return;
}
- return static_cast<QuicErrorCode>(extracted_error_code);
+ // Return the error code (numeric) and the error details string without the
+ // error code prefix. Note that Split returns everything up to, but not
+ // including, the split character, so the length of ed[0] is just the number
+ // of digits in the error number. In removing the prefix, 1 is added to the
+ // length to account for the :
+ QuicStringPiece x = QuicStringPiece(frame->error_details);
+ x.remove_prefix(ed[0].length() + 1);
+ frame->error_details = std::string(x);
+ frame->extracted_error_code =
+ static_cast<QuicErrorCode>(extracted_error_code);
}
#undef ENDPOINT // undef for jumbo builds