@ Override public Promise < HttpResponse > request ( HttpRequest request ) { assert eventloop . inEventloopThread ( ) ; if ( inspector != null ) inspector . onRequest ( request ) ; String host = request . getUrl ( ) . getHost ( ) ; assert host != null ; return asyncDnsClient . resolve4 ( host ) . thenEx ( ( dnsResponse , e ) -> { if ( e == null ) { if ( inspector != null ) inspector . onResolve ( request , dnsResponse ) ; if ( dnsResponse . isSuccessful ( ) ) { //noinspection ConstantConditions - dnsResponse is successful (not null) return doSend ( request , dnsResponse . getRecord ( ) . getIps ( ) ) ; } else { return Promise . ofException ( new DnsQueryException ( AsyncHttpClient . class , dnsResponse ) ) ; } } else { if ( inspector != null ) inspector . onResolveError ( request , e ) ; request . recycle ( ) ; return Promise . ofException ( e ) ; } } ) ; }
Sends the request to server waits the result timeout and handles result with callback