private RequestConfig setTimeout ( Context context ) { int socketTimeout = 0 ; int connectionTimeout = 0 ; if ( context . getCustomerRequestTimeout ( ) != null ) { socketTimeout = context . getCustomerRequestTimeout ( ) ; } else { String reqTimeout = Config . getProperty ( Config . TIMEOUT_REQUEST ) ; if ( StringUtils . hasText ( reqTimeout ) ) { socketTimeout = new Integer ( reqTimeout . trim ( ) ) ; } } String connTimeout = Config . getProperty ( Config . TIMEOUT_CONNECTION ) ; if ( StringUtils . hasText ( connTimeout ) ) { connectionTimeout = new Integer ( connTimeout . trim ( ) ) ; } RequestConfig defaultRequestConfig = RequestConfig . custom ( ) . setSocketTimeout ( socketTimeout ) . setConnectTimeout ( connectionTimeout ) . setConnectionRequestTimeout ( connectionTimeout ) . setCookieSpec ( CookieSpecs . IGNORE_COOKIES ) . build ( ) ; return defaultRequestConfig ; }
Method to set the connection and request timeouts by reading from the configuration file or Context object