test_class.declarator: X_FORWARD_HOST_HEADER = "X-Forwarded-Host"
test_class.modifier: private static final
test_class.original_string: private static final String X_FORWARD_HOST_HEADER = "X-Forwarded-Host";
test_class.type: String
test_class.var_name: X_FORWARD_HOST_HEADER
test_class.declarator: X_GWT_MODULE_HEADER = "X-GWT-Module-Base"
test_class.modifier: private static final
test_class.original_string: private static final String X_GWT_MODULE_HEADER = "X-GWT-Module-Base";
test_class.type: String
test_class.var_name: X_GWT_MODULE_HEADER
test_class.file: common-servlet/src/test/java/org/geomajas/servlet/AutomaticDispatcherUrlServiceTest.java
test_class.identifier: AutomaticDispatcherUrlServiceTest
test_case.body: @Test
  	public void testReverseProxyWithModuleBase() {
  		AutomaticDispatcherUrlService adus = new AutomaticDispatcherUrlService();
  
  		// set mock request in context holder
  		MockHttpServletRequest mockRequest = new MockHttpServletRequest();
  		mockRequest.setScheme("http");
  		mockRequest.setServerName("myhost");
  		mockRequest.setServerPort(80);
  		mockRequest.setContextPath("/test");
  		mockRequest.addHeader(X_FORWARD_HOST_HEADER, "geomajas.org");
  		mockRequest.addHeader(X_GWT_MODULE_HEADER, "http://geomajas.org/app/Module");
  		ServletRequestAttributes attributes = new ServletRequestAttributes(mockRequest);
  		RequestContextHolder.setRequestAttributes(attributes);
  		Assert.assertEquals("http://geomajas.org/app/d/", adus.getDispatcherUrl());
  
  		// clean up
  		RequestContextHolder.setRequestAttributes(null);
  	}
test_case.class_method_signature: AutomaticDispatcherUrlServiceTest.testReverseProxyWithModuleBase()
test_case.full_signature: @Test public void testReverseProxyWithModuleBase()
test_case.identifier: testReverseProxyWithModuleBase
test_case.invocations: setScheme setServerName setServerPort setContextPath addHeader addHeader setRequestAttributes assertEquals getDispatcherUrl setRequestAttributes
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testReverseProxyWithModuleBase()
focal_class.declarator: serialVersionUID = 110L
focal_class.modifier: private static final
focal_class.original_string: private static final long serialVersionUID = 110L;
focal_class.type: long
focal_class.var_name: serialVersionUID
focal_class.declarator: X_FORWARD_HOST_HEADER = "X-Forwarded-Host"
focal_class.modifier: private static final
focal_class.original_string: private static final String X_FORWARD_HOST_HEADER = "X-Forwarded-Host";
focal_class.type: String
focal_class.var_name: X_FORWARD_HOST_HEADER
focal_class.declarator: X_GWT_MODULE_HEADER = "X-GWT-Module-Base"
focal_class.modifier: private static final
focal_class.original_string: private static final String X_GWT_MODULE_HEADER = "X-GWT-Module-Base";
focal_class.type: String
focal_class.var_name: X_GWT_MODULE_HEADER
focal_class.declarator: log = LoggerFactory.getLogger(AutomaticDispatcherUrlService.class)
focal_class.modifier: private final
focal_class.original_string: private final Logger log = LoggerFactory.getLogger(AutomaticDispatcherUrlService.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: localDispatcherUrl
focal_class.modifier: private
focal_class.original_string: private String localDispatcherUrl;
focal_class.type: String
focal_class.var_name: localDispatcherUrl
focal_class.file: common-servlet/src/main/java/org/geomajas/servlet/AutomaticDispatcherUrlService.java
focal_class.identifier: AutomaticDispatcherUrlService
focal_class.interfaces: implements DispatcherUrlService
focal_class.class_method_signature: AutomaticDispatcherUrlService.getDispatcherUrl()
focal_class.full_signature: @Override public String getDispatcherUrl()
focal_class.identifier: getDispatcherUrl
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getDispatcherUrl()
focal_class.class_method_signature: AutomaticDispatcherUrlService.getLocalDispatcherUrl()
focal_class.full_signature: @Override public String getLocalDispatcherUrl()
focal_class.identifier: getLocalDispatcherUrl
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getLocalDispatcherUrl()
focal_class.class_method_signature: AutomaticDispatcherUrlService.setLocalDispatcherUrl(String localDispatcherUrl)
focal_class.full_signature: @Api public void setLocalDispatcherUrl(String localDispatcherUrl)
focal_class.identifier: setLocalDispatcherUrl
focal_class.modifiers: @Api public
focal_class.parameters: (String localDispatcherUrl)
focal_class.return: void
focal_class.signature: void setLocalDispatcherUrl(String localDispatcherUrl)
focal_class.class_method_signature: AutomaticDispatcherUrlService.localize(String externalUrl)
focal_class.full_signature: @Override public String localize(String externalUrl)
focal_class.identifier: localize
focal_class.modifiers: @Override public
focal_class.parameters: (String externalUrl)
focal_class.return: String
focal_class.signature: String localize(String externalUrl)
focal_class.class_method_signature: AutomaticDispatcherUrlService.getBasePathForHostNamePort(HttpServletRequest request, String hostName, int port)
focal_class.full_signature: private String getBasePathForHostNamePort(HttpServletRequest request, String hostName, int port)
focal_class.identifier: getBasePathForHostNamePort
focal_class.modifiers: private
focal_class.parameters: (HttpServletRequest request, String hostName, int port)
focal_class.return: String
focal_class.signature: String getBasePathForHostNamePort(HttpServletRequest request, String hostName, int port)
focal_method.body: @Override
  	public String getDispatcherUrl() {
  		RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
  		if (null == requestAttributes || !(requestAttributes instanceof ServletRequestAttributes)) {
  			log.warn("Trying to automatically get the dispatcher URL, but not running inside a servlet request. " +
  					"You are recommended to use StaticDispatcherUrlService");
  			return "./d/"; // use relative URL as back-up, will fail in many cases
  		}
  
  		HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
  
  		String serverName = request.getServerName();
  
  		// X-Forwarded-Host if behind a reverse proxy, fallback to general method.
  		// Alternative we could use the gwt module url to guess the real URL.
  		if (null != request.getHeader(X_FORWARD_HOST_HEADER)) {
  			log.warn("AutomaticDispatcherService detected a X-Forwarded-Host header which means the server is " +
  					"accessed using a reverse proxy server. This might cause problems in some cases. You are " +
  					"recommended to configure your tomcat connector to be aware of the original url. " +
  					"(see http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html )");
  			String gwtModuleBase = request.getHeader(X_GWT_MODULE_HEADER);
  			if (null != gwtModuleBase) {
  				// Get last slash in the gwtModuleBase, ignoring the trailing slash.
  				int contextEndIndex = gwtModuleBase.lastIndexOf("/", gwtModuleBase.length() - 2);
  				if (contextEndIndex > -1) {
  					return gwtModuleBase.substring(0, contextEndIndex) + "/d/";
  				}
  			} else {
  				// else get the information from the X-forwarded-host header and default to the standard behaviour 
  				serverName = request.getHeader(X_FORWARD_HOST_HEADER);
  			}
  		}
  
  		return getBasePathForHostNamePort(request, serverName, request.getServerPort());
  	}
focal_method.class_method_signature: AutomaticDispatcherUrlService.getDispatcherUrl()
focal_method.full_signature: @Override public String getDispatcherUrl()
focal_method.identifier: getDispatcherUrl
focal_method.invocations: getRequestAttributes warn getRequest getServerName getHeader warn getHeader lastIndexOf length substring getHeader getBasePathForHostNamePort getServerPort
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: String
focal_method.signature: String getDispatcherUrl()