本文整理匯總了Java中org.restlet.Request.getRootRef方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.getRootRef方法的具體用法?Java Request.getRootRef怎麽用?Java Request.getRootRef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.restlet.Request
的用法示例。
在下文中一共展示了Request.getRootRef方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getApplicationRoot
import org.restlet.Request; //導入方法依賴的package包/類
/**
* The application's root URI on the virtual host that routed the current
* request.
*
* @return The application's root
*/
public Reference getApplicationRoot()
{
Request request = getRequest();
Reference root = CapturingRedirector.getCapturedRootReference( request );
if( root == null )
root = request.getRootRef();
return root;
}
示例2: beforeHandle
import org.restlet.Request; //導入方法依賴的package包/類
@Override
protected int beforeHandle( Request request, Response response )
{
if( !isApplying() )
return CONTINUE;
String forwardedScheme = request.getHeaders().getFirstValue( X_FORWARDED_PROTO_HEADER );
String forwardedDomain = request.getHeaders().getFirstValue( X_FORWARDED_HOST_HEADER );
String forwardedPortString = request.getHeaders().getFirstValue( X_FORWARDED_PORT_HEADER );
if( ( forwardedScheme != null ) || ( forwardedDomain != null ) || ( forwardedPortString != null ) )
{
int forwardedPort = -1;
if( forwardedDomain != null )
{
int colon = forwardedDomain.indexOf( ':' );
if( colon != -1 )
{
// Parse host:port
try
{
forwardedPort = Integer.parseInt( forwardedDomain.substring( 0, colon ) );
}
catch( NumberFormatException x )
{
// Invalid
}
forwardedDomain = forwardedDomain.substring( 0, colon );
}
}
if( forwardedPortString != null )
// Note: will override port in X-Forwarded-Host
forwardedPort = Integer.parseInt( forwardedPortString );
Reference reference;
reference = request.getResourceRef();
if( reference != null )
{
apply( reference, forwardedScheme, forwardedDomain, forwardedPort );
request.setResourceRef( reference );
}
reference = request.getRootRef();
if( reference != null )
{
apply( reference, forwardedScheme, forwardedDomain, forwardedPort );
request.setRootRef( reference );
}
reference = request.getOriginalRef();
if( reference != null )
{
apply( reference, forwardedScheme, forwardedDomain, forwardedPort );
request.setOriginalRef( reference );
}
}
return CONTINUE;
}