@@ -448,18 +448,14 @@ extension HTTPConnectionPool: HTTPConnectionRequester {
448448 }
449449
450450 func http2ConnectionCreated( _ connection: HTTP2Connection , maximumStreams: Int ) {
451- preconditionFailure ( " Did not expect http/2 connections right now. " )
452- // let action = self.stateLock.withLock { () -> StateMachine.Action in
453- // if let settings = connection.settings {
454- // return self._state.newHTTP2ConnectionCreated(.http2(connection), settings: settings)
455- // } else {
456- // // immidiate connection closure before we can register with state machine
457- // // is the only reason we don't have settings
458- // struct ImmidiateConnectionClose: Error {}
459- // return self._state.failedToCreateNewConnection(ImmidiateConnectionClose(), connectionID: connection.id)
460- // }
461- // }
462- // self.run(action: action)
451+ self . logger. trace ( " successfully created connection " , metadata: [
452+ " ahc-connection-id " : " \( connection. id) " ,
453+ " ahc-http-version " : " http/2 " ,
454+ " ahc-max-streams " : " \( maximumStreams) " ,
455+ ] )
456+ self . modifyStateAndRunActions {
457+ $0. newHTTP2ConnectionCreated ( . http2( connection) , maxConcurrentStreams: maximumStreams)
458+ }
463459 }
464460
465461 func failedToCreateHTTPConnection( _ connectionID: HTTPConnectionPool . Connection . ID , error: Error ) {
@@ -497,27 +493,44 @@ extension HTTPConnectionPool: HTTP1ConnectionDelegate {
497493
498494extension HTTPConnectionPool : HTTP2ConnectionDelegate {
499495 func http2Connection( _ connection: HTTP2Connection , newMaxStreamSetting: Int ) {
500- // ignore for now
496+ self . logger. debug ( " new max stream setting " , metadata: [
497+ " ahc-connection-id " : " \( connection. id) " ,
498+ " ahc-http-version " : " http/2 " ,
499+ " ahc-max-streams " : " \( newMaxStreamSetting) " ,
500+ ] )
501+ self . modifyStateAndRunActions {
502+ $0. newHTTP2MaxConcurrentStreamsReceived ( connection. id, newMaxStreams: newMaxStreamSetting)
503+ }
501504 }
502505
503- func http2ConnectionGoAwayReceived( _: HTTP2Connection ) {
504- // ignore for now
506+ func http2ConnectionGoAwayReceived( _ connection: HTTP2Connection ) {
507+ self . logger. debug ( " connection go away received " , metadata: [
508+ " ahc-connection-id " : " \( connection. id) " ,
509+ " ahc-http-version " : " http/2 " ,
510+ ] )
511+ self . modifyStateAndRunActions {
512+ $0. http2ConnectionGoAwayReceived ( connection. id)
513+ }
505514 }
506515
507- func http2ConnectionClosed( _: HTTP2Connection ) {
508- // ignore for now
509- // let action = self.stateLock.withLock {
510- // self._state.connectionClosed(connection.id)
511- // }
512- // self.run(action: action)
516+ func http2ConnectionClosed( _ connection: HTTP2Connection ) {
517+ self . logger. debug ( " connection closed " , metadata: [
518+ " ahc-connection-id " : " \( connection. id) " ,
519+ " ahc-http-version " : " http/2 " ,
520+ ] )
521+ self . modifyStateAndRunActions {
522+ $0. http2ConnectionClosed ( connection. id)
523+ }
513524 }
514525
515526 func http2ConnectionStreamClosed( _ connection: HTTP2Connection , availableStreams: Int ) {
516- // ignore for now
517- // let action = self.stateLock.withLock {
518- // self._state.http2ConnectionStreamClosed(connection.id, availableStreams: availableStreams)
519- // }
520- // self.run(action: action)
527+ self . logger. trace ( " stream closed " , metadata: [
528+ " ahc-connection-id " : " \( connection. id) " ,
529+ " ahc-http-version " : " http/2 " ,
530+ ] )
531+ self . modifyStateAndRunActions {
532+ $0. http2ConnectionStreamClosed ( connection. id)
533+ }
521534 }
522535}
523536
0 commit comments