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


Java Request.setRootRef方法代碼示例

本文整理匯總了Java中org.restlet.Request.setRootRef方法的典型用法代碼示例。如果您正苦於以下問題:Java Request.setRootRef方法的具體用法?Java Request.setRootRef怎麽用?Java Request.setRootRef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.restlet.Request的用法示例。


在下文中一共展示了Request.setRootRef方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testResolveResourceId

import org.restlet.Request; //導入方法依賴的package包/類
@Test
public void testResolveResourceId () throws Exception {
  Request testRequest = new Request();
  Reference rootRef = new Reference("http://solr.apache.org/");
  testRequest.setRootRef(rootRef);

  Reference resourceRef = new Reference("http://solr.apache.org/schema/analysis/synonyms/de");
  testRequest.setResourceRef(resourceRef);

  String resourceId = RestManager.ManagedEndpoint.resolveResourceId(testRequest);
  assertEquals(resourceId, "/schema/analysis/synonyms/de");
}
 
開發者ID:europeana,項目名稱:search,代碼行數:13,代碼來源:TestRestManager.java

示例2: testResolveResourceIdDecodeUrlEntities

import org.restlet.Request; //導入方法依賴的package包/類
@Test
public void testResolveResourceIdDecodeUrlEntities () throws Exception {
  Request testRequest = new Request();
  Reference rootRef = new Reference("http://solr.apache.org/");
  testRequest.setRootRef(rootRef);

  Reference resourceRef = new Reference("http://solr.apache.org/schema/analysis/synonyms/de/%C3%84ndern");
  testRequest.setResourceRef(resourceRef);

  String resourceId = RestManager.ManagedEndpoint.resolveResourceId(testRequest);
  assertEquals(resourceId, "/schema/analysis/synonyms/de/Ändern");
}
 
開發者ID:europeana,項目名稱:search,代碼行數:13,代碼來源:TestRestManager.java

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