@@ -148,9 +148,9 @@ func (cc *ClientConn) acceptStreams() {
148
148
// "Clients MUST treat receipt of a server-initiated bidirectional
149
149
// stream as a connection error of type H3_STREAM_CREATION_ERROR [...]"
150
150
// https://www.rfc-editor.org/rfc/rfc9114.html#section-6.1-3
151
- cc .qconn . Abort ( & quic. ApplicationError {
152
- Code : uint64 ( errH3StreamCreationError ) ,
153
- Reason : "server created bidirectional stream" ,
151
+ cc .abort ( & connectionError {
152
+ code : errH3StreamCreationError ,
153
+ message : "server created bidirectional stream" ,
154
154
})
155
155
return
156
156
}
@@ -162,9 +162,9 @@ func (cc *ClientConn) handleStream(st *stream) {
162
162
// Unidirectional stream header: One varint with the stream type.
163
163
stype , err := st .readVarint ()
164
164
if err != nil {
165
- cc .qconn . Abort ( & quic. ApplicationError {
166
- Code : uint64 ( errH3StreamCreationError ) ,
167
- Reason : "error reading unidirectional stream header" ,
165
+ cc .abort ( & connectionError {
166
+ code : errH3StreamCreationError ,
167
+ message : "error reading unidirectional stream header" ,
168
168
})
169
169
return
170
170
}
@@ -190,13 +190,13 @@ func (cc *ClientConn) handleStream(st *stream) {
190
190
err = nil
191
191
}
192
192
if err == io .EOF {
193
- err = & quic. ApplicationError {
194
- Code : uint64 ( errH3ClosedCriticalStream ) ,
195
- Reason : streamType (stype ).String () + " stream closed" ,
193
+ err = & connectionError {
194
+ code : errH3ClosedCriticalStream ,
195
+ message : streamType (stype ).String () + " stream closed" ,
196
196
}
197
197
}
198
198
if err != nil {
199
- cc .qconn . Abort (err )
199
+ cc .abort (err )
200
200
}
201
201
}
202
202
@@ -205,9 +205,9 @@ func (cc *ClientConn) checkStreamCreation(stype streamType, name string) error {
205
205
defer cc .mu .Unlock ()
206
206
bit := uint8 (1 ) << stype
207
207
if cc .streamsCreated & bit != 0 {
208
- return & quic. ApplicationError {
209
- Code : uint64 ( errH3StreamCreationError ) ,
210
- Reason : "multiple " + name + " streams created" ,
208
+ return & connectionError {
209
+ code : errH3StreamCreationError ,
210
+ message : "multiple " + name + " streams created" ,
211
211
}
212
212
}
213
213
cc .streamsCreated |= bit
@@ -251,9 +251,9 @@ func (cc *ClientConn) handleControlStream(st *stream) error {
251
251
// greater than currently allowed on the connection,
252
252
// this MUST be treated as a connection error of type H3_ID_ERROR."
253
253
// https://www.rfc-editor.org/rfc/rfc9114.html#section-7.2.3-7
254
- return & quic. ApplicationError {
255
- Code : uint64 ( errH3IDError ) ,
256
- Reason : "CANCEL_PUSH received when no MAX_PUSH_ID has been sent" ,
254
+ return & connectionError {
255
+ code : errH3IDError ,
256
+ message : "CANCEL_PUSH received when no MAX_PUSH_ID has been sent" ,
257
257
}
258
258
case frameTypeGoaway :
259
259
// TODO: Wait for requests to complete before closing connection.
@@ -293,8 +293,20 @@ func (cc *ClientConn) handlePushStream(*stream) error {
293
293
// "A client MUST treat receipt of a push stream as a connection error
294
294
// of type H3_ID_ERROR when no MAX_PUSH_ID frame has been sent [...]"
295
295
// https://www.rfc-editor.org/rfc/rfc9114.html#section-4.6-3
296
- return & quic.ApplicationError {
297
- Code : uint64 (errH3IDError ),
298
- Reason : "push stream created when no MAX_PUSH_ID has been sent" ,
296
+ return & connectionError {
297
+ code : errH3IDError ,
298
+ message : "push stream created when no MAX_PUSH_ID has been sent" ,
299
+ }
300
+ }
301
+
302
+ // abort closes the connection with an error.
303
+ func (cc * ClientConn ) abort (err error ) {
304
+ if e , ok := err .(* connectionError ); ok {
305
+ cc .qconn .Abort (& quic.ApplicationError {
306
+ Code : uint64 (e .code ),
307
+ Reason : e .message ,
308
+ })
309
+ } else {
310
+ cc .qconn .Abort (err )
299
311
}
300
312
}
0 commit comments