diff --git a/http3/error_codes.go b/http3/error_codes.go index 01e38377..a26189b9 100644 --- a/http3/error_codes.go +++ b/http3/error_codes.go @@ -9,80 +9,65 @@ import ( type errorCode quic.ErrorCode const ( - errorNoError errorCode = 0x0 - errorWrongSettingsDirection errorCode = 0x1 - errorPushRefused errorCode = 0x2 - errorInternalError errorCode = 0x3 - errorPushAlreadyInCache errorCode = 0x4 - errorRequestCanceled errorCode = 0x5 - errorIncompleteRequest errorCode = 0x6 - errorConnectError errorCode = 0x7 - errorExcessiveLoad errorCode = 0x8 - errorVersionFallback errorCode = 0x9 - errorWrongStream errorCode = 0xa - errorLimitExceeded errorCode = 0xb - errorDuplicatePush errorCode = 0xc - errorUnknownStreamType errorCode = 0xd - errorWrongStreamCount errorCode = 0xe - errorClosedCriticalStream errorCode = 0xf - errorWrongStreamDirection errorCode = 0x10 - errorEarlyResponse errorCode = 0x11 - errorMissingSettings errorCode = 0x12 - errorUnexpectedFrame errorCode = 0x13 - errorRequestRejected errorCode = 0x14 - errorGeneralProtocolError errorCode = 0xff + errorNoError errorCode = 0x100 + errorGeneralProtocolError errorCode = 0x101 + errorInternalError errorCode = 0x102 + errorStreamCreationError errorCode = 0x103 + errorClosedCriticalStream errorCode = 0x104 + errorUnexpectedFrame errorCode = 0x105 + errorFrameError errorCode = 0x106 + errorExcessiveLoad errorCode = 0x107 + errorWrongStream errorCode = 0x108 + errorIDError errorCode = 0x109 + errorSettingsError errorCode = 0x10a + errorMissingSettings errorCode = 0x10b + errorRequestRejected errorCode = 0x10c + errorRequestCanceled errorCode = 0x10d + errorRequestIncomplete errorCode = 0x10e + errorEarlyResponse errorCode = 0x10f + errorConnectError errorCode = 0x110 + errorVersionFallback errorCode = 0x111 ) func (e errorCode) String() string { switch e { case errorNoError: return "HTTP_NO_ERROR" - case errorWrongSettingsDirection: - return "HTTP_WRONG_SETTING_DIRECTION" - case errorPushRefused: - return "HTTP_PUSH_REFUSED" - case errorInternalError: - return "HTTP_INTERNAL_ERROR" - case errorPushAlreadyInCache: - return "HTTP_PUSH_ALREADY_IN_CACHE" - case errorRequestCanceled: - return "HTTP_REQUEST_CANCELLED" - case errorIncompleteRequest: - return "HTTP_INCOMPLETE_REQUEST" - case errorConnectError: - return "HTTP_CONNECT_ERROR" - case errorExcessiveLoad: - return "HTTP_EXCESSIVE_LOAD" - case errorVersionFallback: - return "HTTP_VERSION_FALLBACK" - case errorWrongStream: - return "HTTP_WRONG_STREAM" - case errorLimitExceeded: - return "HTTP_LIMIT_EXCEEDED" - case errorDuplicatePush: - return "HTTP_DUPLICATE_PUSH" - case errorUnknownStreamType: - return "HTTP_UNKNOWN_STREAM_TYPE" - case errorWrongStreamCount: - return "HTTP_WRONG_STREAM_COUNT" - case errorClosedCriticalStream: - return "HTTP_CLOSED_CRITICAL_STREAM" - case errorWrongStreamDirection: - return "HTTP_WRONG_STREAM_DIRECTION" - case errorEarlyResponse: - return "HTTP_EARLY_RESPONSE" - case errorMissingSettings: - return "HTTP_MISSING_SETTINGS" - case errorUnexpectedFrame: - return "HTTP_UNEXPECTED_FRAME" - case errorRequestRejected: - return "HTTP_REQUEST_REJECTED" case errorGeneralProtocolError: return "HTTP_GENERAL_PROTOCOL_ERROR" + case errorInternalError: + return "HTTP_INTERNAL_ERROR" + case errorStreamCreationError: + return "HTTP_STREAM_CREATION_ERROR" + case errorClosedCriticalStream: + return "HTTP_CLOSED_CRITICAL_STREAM" + case errorUnexpectedFrame: + return "HTTP_UNEXPECTED_FRAME" + case errorFrameError: + return "HTTP_FRAME_ERROR" + case errorExcessiveLoad: + return "HTTP_EXCESSIVE_LOAD" + case errorWrongStream: + return "HTTP_WRONG_STREAM" + case errorIDError: + return "HTTP_ID_ERROR" + case errorSettingsError: + return "HTTP_SETTINGS_ERROR" + case errorMissingSettings: + return "HTTP_MISSING_SETTINGS" + case errorRequestRejected: + return "HTTP_REQUEST_REJECTED" + case errorRequestCanceled: + return "HTTP_REQUEST_CANCELLED" + case errorRequestIncomplete: + return "HTTP_INCOMPLETE_REQUEST" + case errorEarlyResponse: + return "HTTP_EARLY_RESPONSE" + case errorConnectError: + return "HTTP_CONNECT_ERROR" + case errorVersionFallback: + return "HTTP_VERSION_FALLBACK" default: - if e >= 0x100 && e < 0x200 { - return fmt.Sprintf("HTTP_MALFORMED_FRAME: %#x", uint16(e-0x100)) - } return fmt.Sprintf("unknown error code: %#x", uint16(e)) } } diff --git a/http3/error_codes_test.go b/http3/error_codes_test.go index 706409e6..e4aae37e 100644 --- a/http3/error_codes_test.go +++ b/http3/error_codes_test.go @@ -33,10 +33,6 @@ var _ = Describe("error codes", func() { } }) - It("has a string represenation for frame parsing errors", func() { - Expect(errorCode(0x142).String()).To(Equal("HTTP_MALFORMED_FRAME: 0x42")) - }) - It("has a string representation for unknown error codes", func() { Expect(errorCode(0x1337).String()).To(Equal("unknown error code: 0x1337")) }) diff --git a/http3/server.go b/http3/server.go index c65e4631..3056d7b2 100644 --- a/http3/server.go +++ b/http3/server.go @@ -187,12 +187,12 @@ func (s *Server) handleRequest(str quic.Stream, decoder *qpack.Decoder) error { return errors.New("expected first frame to be a headers frame") } if hf.Length > s.maxHeaderBytes() { - str.CancelWrite(quic.ErrorCode(errorLimitExceeded)) + str.CancelWrite(quic.ErrorCode(errorFrameError)) return fmt.Errorf("Headers frame too large: %d bytes (max: %d)", hf.Length, s.maxHeaderBytes()) } headerBlock := make([]byte, hf.Length) if _, err := io.ReadFull(str, headerBlock); err != nil { - str.CancelWrite(quic.ErrorCode(errorIncompleteRequest)) + str.CancelWrite(quic.ErrorCode(errorRequestIncomplete)) return err } hfs, err := decoder.DecodeFull(headerBlock) diff --git a/http3/server_test.go b/http3/server_test.go index 8ef958f5..a9b96fc5 100644 --- a/http3/server_test.go +++ b/http3/server_test.go @@ -197,7 +197,7 @@ var _ = Describe("Server", func() { return responseBuf.Write(p) }).AnyTimes() - str.EXPECT().CancelWrite(quic.ErrorCode(errorLimitExceeded)) + str.EXPECT().CancelWrite(quic.ErrorCode(errorFrameError)) err := s.handleRequest(str, qpackDecoder) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Headers frame too large")) diff --git a/integrationtests/self/http_test.go b/integrationtests/self/http_test.go index ff44c343..0074e54b 100644 --- a/integrationtests/self/http_test.go +++ b/integrationtests/self/http_test.go @@ -202,7 +202,7 @@ var _ = Describe("HTTP tests", func() { serr, ok := err.(streamCancelError) Expect(ok).To(BeTrue()) Expect(serr.Canceled()).To(BeTrue()) - Expect(serr.ErrorCode()).To(BeEquivalentTo(5)) + Expect(serr.ErrorCode()).To(BeEquivalentTo(0x10d)) return } }