public RequestTemplate target ( String target ) { /* target can be empty */ if ( Util . isBlank ( target ) ) { return this ; } /* verify that the target contains the scheme, host and port */ if ( ! UriUtils . isAbsolute ( target ) ) { throw new IllegalArgumentException ( "target values must be absolute." ) ; } if ( target . endsWith ( "/" ) ) { target = target . substring ( 0 , target . length ( ) - 1 ) ; } try { /* parse the target */ URI targetUri = URI . create ( target ) ; if ( Util . isNotBlank ( targetUri . getRawQuery ( ) ) ) { /* * target has a query string, we need to make sure that they are recorded as queries */ this . extractQueryTemplates ( targetUri . getRawQuery ( ) , true ) ; } /* strip the query string */ this . target = targetUri . getScheme ( ) + "://" + targetUri . getAuthority ( ) + targetUri . getPath ( ) ; if ( targetUri . getFragment ( ) != null ) { this . fragment = "#" + targetUri . getFragment ( ) ; } } catch ( IllegalArgumentException iae ) { /* the uri provided is not a valid one, we can't continue */ throw new IllegalArgumentException ( "Target is not a valid URI." , iae ) ; } return this ; }
Set the target host for this request .