當前位置: 首頁>>代碼示例>>Java>>正文


Java Request.getRootRef方法代碼示例

本文整理匯總了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;
}
 
開發者ID:tliron,項目名稱:prudence,代碼行數:15,代碼來源:ConversationService.java

示例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;
}
 
開發者ID:tliron,項目名稱:prudence,代碼行數:62,代碼來源:ForwardedFilter.java


注:本文中的org.restlet.Request.getRootRef方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。