update HTTP/3 errors

* rename HTTP_UNEXPECTED_FRAME to HTTP_FRAME_UNEXPECTED
* remove the HTTP_WRONG_STREAM error
* rename errors from HTTP_ to H3_
This commit is contained in:
Marten Seemann
2019-10-23 09:40:19 +07:00
parent 4af8a33c3f
commit ea0050e2a2
6 changed files with 33 additions and 36 deletions

View File

@@ -204,7 +204,7 @@ func (c *client) doRequest(
}
hf, ok := frame.(*headersFrame)
if !ok {
return nil, newConnError(errorUnexpectedFrame, errors.New("expected first frame to be a HEADERS frame"))
return nil, newConnError(errorFrameUnexpected, errors.New("expected first frame to be a HEADERS frame"))
}
if hf.Length > c.maxHeaderBytes() {
return nil, newStreamError(errorFrameError, fmt.Errorf("HEADERS frame too large: %d bytes (max: %d)", hf.Length, c.maxHeaderBytes()))

View File

@@ -271,7 +271,7 @@ var _ = Describe("Client", func() {
It("closes the connection when the first frame is not a HEADERS frame", func() {
buf := &bytes.Buffer{}
(&dataFrame{Length: 0x42}).Write(buf)
sess.EXPECT().CloseWithError(quic.ErrorCode(errorUnexpectedFrame), gomock.Any())
sess.EXPECT().CloseWithError(quic.ErrorCode(errorFrameUnexpected), gomock.Any())
closed := make(chan struct{})
str.EXPECT().Close().Do(func() { close(closed) })
str.EXPECT().Read(gomock.Any()).DoAndReturn(func(b []byte) (int, error) {

View File

@@ -14,59 +14,56 @@ const (
errorInternalError errorCode = 0x102
errorStreamCreationError errorCode = 0x103
errorClosedCriticalStream errorCode = 0x104
errorUnexpectedFrame errorCode = 0x105
errorFrameUnexpected 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
errorIDError errorCode = 0x108
errorSettingsError errorCode = 0x109
errorMissingSettings errorCode = 0x10a
errorRequestRejected errorCode = 0x10b
errorRequestCanceled errorCode = 0x10c
errorRequestIncomplete errorCode = 0x10d
errorEarlyResponse errorCode = 0x10e
errorConnectError errorCode = 0x10f
errorVersionFallback errorCode = 0x110
)
func (e errorCode) String() string {
switch e {
case errorNoError:
return "HTTP_NO_ERROR"
return "H3_NO_ERROR"
case errorGeneralProtocolError:
return "HTTP_GENERAL_PROTOCOL_ERROR"
return "H3_GENERAL_PROTOCOL_ERROR"
case errorInternalError:
return "HTTP_INTERNAL_ERROR"
return "H3_INTERNAL_ERROR"
case errorStreamCreationError:
return "HTTP_STREAM_CREATION_ERROR"
return "H3_STREAM_CREATION_ERROR"
case errorClosedCriticalStream:
return "HTTP_CLOSED_CRITICAL_STREAM"
case errorUnexpectedFrame:
return "HTTP_UNEXPECTED_FRAME"
return "H3_CLOSED_CRITICAL_STREAM"
case errorFrameUnexpected:
return "H3_FRAME_UNEXPECTED"
case errorFrameError:
return "HTTP_FRAME_ERROR"
return "H3_FRAME_ERROR"
case errorExcessiveLoad:
return "HTTP_EXCESSIVE_LOAD"
case errorWrongStream:
return "HTTP_WRONG_STREAM"
return "H3_EXCESSIVE_LOAD"
case errorIDError:
return "HTTP_ID_ERROR"
return "H3_ID_ERROR"
case errorSettingsError:
return "HTTP_SETTINGS_ERROR"
return "H3_SETTINGS_ERROR"
case errorMissingSettings:
return "HTTP_MISSING_SETTINGS"
return "H3_MISSING_SETTINGS"
case errorRequestRejected:
return "HTTP_REQUEST_REJECTED"
return "H3_REQUEST_REJECTED"
case errorRequestCanceled:
return "HTTP_REQUEST_CANCELLED"
return "H3_REQUEST_CANCELLED"
case errorRequestIncomplete:
return "HTTP_INCOMPLETE_REQUEST"
return "H3_INCOMPLETE_REQUEST"
case errorEarlyResponse:
return "HTTP_EARLY_RESPONSE"
return "H3_EARLY_RESPONSE"
case errorConnectError:
return "HTTP_CONNECT_ERROR"
return "H3_CONNECT_ERROR"
case errorVersionFallback:
return "HTTP_VERSION_FALLBACK"
return "H3_VERSION_FALLBACK"
default:
return fmt.Sprintf("unknown error code: %#x", uint16(e))
}

View File

@@ -213,7 +213,7 @@ func (s *Server) handleRequest(str quic.Stream, decoder *qpack.Decoder) requestE
}
hf, ok := frame.(*headersFrame)
if !ok {
return newConnError(errorUnexpectedFrame, errors.New("expected first frame to be a HEADERS frame"))
return newConnError(errorFrameUnexpected, errors.New("expected first frame to be a HEADERS frame"))
}
if hf.Length > s.maxHeaderBytes() {
return newStreamError(errorFrameError, fmt.Errorf("HEADERS frame too large: %d bytes (max: %d)", hf.Length, s.maxHeaderBytes()))

View File

@@ -248,7 +248,7 @@ var _ = Describe("Server", func() {
done := make(chan struct{})
sess.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(code quic.ErrorCode, _ string) {
Expect(code).To(Equal(quic.ErrorCode(errorUnexpectedFrame)))
Expect(code).To(Equal(quic.ErrorCode(errorFrameUnexpected)))
close(done)
})
s.handleConn(sess)

View File

@@ -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(0x10d))
Expect(serr.ErrorCode()).To(BeEquivalentTo(0x10c))
return
}
}