public HttpRequestInitializer getHttpRequestInitializer ( final ServiceOptions < ? , ? > serviceOptions ) { Credentials scopedCredentials = serviceOptions . getScopedCredentials ( ) ; final HttpRequestInitializer delegate = scopedCredentials != null && scopedCredentials != NoCredentials . getInstance ( ) ? new HttpCredentialsAdapter ( scopedCredentials ) : null ; HeaderProvider internalHeaderProvider = getInternalHeaderProviderBuilder ( serviceOptions ) . build ( ) ; final HeaderProvider headerProvider = serviceOptions . getMergedHeaderProvider ( internalHeaderProvider ) ; return new HttpRequestInitializer ( ) { @ Override public void initialize ( HttpRequest httpRequest ) throws IOException { if ( delegate != null ) { delegate . initialize ( httpRequest ) ; } if ( connectTimeout >= 0 ) { httpRequest . setConnectTimeout ( connectTimeout ) ; } if ( readTimeout >= 0 ) { httpRequest . setReadTimeout ( readTimeout ) ; } HttpHeadersUtils . setHeaders ( httpRequest . getHeaders ( ) , headerProvider . getHeaders ( ) ) ; } } ; }
Returns a request initializer responsible for initializing requests according to service options .