private int getTimeout ( final ITransaction transaction , final WebdavRequest req ) { int lockDuration = DEFAULT_TIMEOUT ; String lockDurationStr = req . getHeader ( "Timeout" ) ; if ( lockDurationStr == null ) { lockDuration = DEFAULT_TIMEOUT ; } else { final int commaPos = lockDurationStr . indexOf ( ' ' ) ; // if multiple timeouts, just use the first one if ( commaPos != - 1 ) { lockDurationStr = lockDurationStr . substring ( 0 , commaPos ) ; } if ( lockDurationStr . startsWith ( "Second-" ) ) { lockDuration = new Integer ( lockDurationStr . substring ( 7 ) ) . intValue ( ) ; } else { if ( lockDurationStr . equalsIgnoreCase ( "infinity" ) ) { lockDuration = MAX_TIMEOUT ; } else { try { lockDuration = new Integer ( lockDurationStr ) . intValue ( ) ; } catch ( final NumberFormatException e ) { lockDuration = MAX_TIMEOUT ; } } } if ( lockDuration <= 0 ) { lockDuration = DEFAULT_TIMEOUT ; } if ( lockDuration > MAX_TIMEOUT ) { lockDuration = MAX_TIMEOUT ; } } return lockDuration ; }
Ties to read the timeout from request