You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/01/08 02:54:36 UTC
svn commit: r1056592 - in
/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5:
internal/services/ internal/test/ services/
Author: hlship
Date: Sat Jan 8 01:54:35 2011
New Revision: 1056592
URL: http://svn.apache.org/viewvc?rev=1056592&view=rev
Log:
TAP5-1372: Add Request.getServerPort() and change BaseURLSourceImpl() to use it.
Modified:
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BaseURLSourceImpl.java
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestImpl.java
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableRequestImpl.java
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/BaseURLSource.java
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java
tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java
Modified: tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BaseURLSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BaseURLSourceImpl.java?rev=1056592&r1=1056591&r2=1056592&view=diff
==============================================================================
--- tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BaseURLSourceImpl.java (original)
+++ tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/BaseURLSourceImpl.java Sat Jan 8 01:54:35 2011
@@ -1,4 +1,4 @@
-// Copyright 2008, 2010 The Apache Software Foundation
+// Copyright 2008, 2010, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ public class BaseURLSourceImpl implement
public String getBaseURL(boolean secure)
{
- int port = request.getLocalPort();
+ int port = request.getServerPort();
int schemeDefaultPort = request.isSecure() ? 443 : 80;
Modified: tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestImpl.java?rev=1056592&r1=1056591&r2=1056592&view=diff
==============================================================================
--- tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestImpl.java (original)
+++ tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/RequestImpl.java Sat Jan 8 01:54:35 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2010, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -186,4 +186,10 @@ public class RequestImpl implements Requ
return request.getLocalPort();
}
+ /** @since 5.2.5 */
+ public int getServerPort()
+ {
+ return request.getServerPort();
+ }
+
}
Modified: tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableRequestImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableRequestImpl.java?rev=1056592&r1=1056591&r2=1056592&view=diff
==============================================================================
--- tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableRequestImpl.java (original)
+++ tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/internal/test/TestableRequestImpl.java Sat Jan 8 01:54:35 2011
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008, 2009, 2010 The Apache Software Foundation
+// Copyright 2007, 2008, 2009, 2010, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -240,4 +240,13 @@ public class TestableRequestImpl impleme
return 80;
}
+ /**
+ * Always returns 80.
+ *
+ * @since 5.2.5
+ */
+ public int getServerPort()
+ {
+ return 80;
+ }
}
Modified: tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/BaseURLSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/BaseURLSource.java?rev=1056592&r1=1056591&r2=1056592&view=diff
==============================================================================
--- tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/BaseURLSource.java (original)
+++ tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/BaseURLSource.java Sat Jan 8 01:54:35 2011
@@ -1,10 +1,10 @@
-// Copyright 2008 The Apache Software Foundation
+// Copyright 2008, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,24 +14,27 @@
package org.apache.tapestry5.services;
+import org.apache.tapestry5.ioc.services.ServiceOverride;
+
/**
- * Used when switching between normal/insecure (HTTP) and secure (HTTPS) mode. When a switch occurs, it is no longer
- * possible to use relative URLs, instead absolute URLs must be generated. The default implementation of this is
- * simple-minded: it just tacks the correct scheme in front of {@link org.apache.tapestry5.services.Request#getServerName()}.
- * In production, behind a firewall, it is often necessary to do a bit more, since <code>getServerName()</code> will
- * often be the name of the internal server (not visible to the client web browser), and a hard-coded name of a server
- * that <em>is</em> visible to the web browser is needed. Further, in testing, non-default ports are often used. In
- * those cases, an overriding contribution to the {@link org.apache.tapestry5.services.Alias} service will allow a custom
- * implementation to supercede the default version.
+ * Used when switching between normal/insecure (HTTP) and secure (HTTPS) mode. When a switch occurs, it is no longer
+ * possible to use just paths, instead absolute URLs (including the scheme, hostname and possibly port) must be
+ * generated. The default implementation of this is simple-minded: it just tacks the correct scheme in front of
+ * {@link org.apache.tapestry5.services.Request#getServerName()}. In production, behind a firewall, it is often
+ * necessary to do a bit more, since <code>getServerName()</code> will often be the name of the internal server (not
+ * visible to the client web browser), and a hard-coded name of a server that <em>is</em> visible to the web browser
+ * is needed. Further, in testing, non-default ports are often used. In those cases, an overriding contribution to the
+ * {@link ServiceOverride} service will allow a custom implementation to supercede the default version.
*/
public interface BaseURLSource
{
/**
* Returns the base portion of the URL, before the context path and servlet path are appended. The return value
- * should <em>not</em> end with a slash; it should end after the host name, or after the port number. The context
+ * should <em>not</em> end with a slash; it should end after the host name, or after the port number. The context
* path, servlet path, and path info will be appended to the returned value.
- *
- * @param secure whether a secure "https" or insecure "http" base URL should be returned
+ *
+ * @param secure
+ * whether a secure "https" or insecure "http" base URL should be returned
* @return the base URL ready for additional extensions
*/
String getBaseURL(boolean secure);
Modified: tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java?rev=1056592&r1=1056591&r2=1056592&view=diff
==============================================================================
--- tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java (original)
+++ tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/DelegatingRequest.java Sat Jan 8 01:54:35 2011
@@ -1,10 +1,10 @@
-// Copyright 2009, 2010 The Apache Software Foundation
+// Copyright 2009, 2010, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@@ -147,4 +147,8 @@ public class DelegatingRequest implement
return request.getLocalPort();
}
+ public int getServerPort()
+ {
+ return request.getServerPort();
+ }
}
Modified: tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java?rev=1056592&r1=1056591&r2=1056592&view=diff
==============================================================================
--- tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java (original)
+++ tapestry/tapestry5/branches/maint-5-2/tapestry-core/src/main/java/org/apache/tapestry5/services/Request.java Sat Jan 8 01:54:35 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2011 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -172,4 +172,15 @@ public interface Request
* @since 5.2.0
*/
int getLocalPort();
+
+ /**
+ * Returns the port number to which the request was sent.
+ * It is the value of the part after ":" in the <code>Host</code> header, if any, or the server port where the
+ * client connection
+ * was accepted on.
+ *
+ * @return an integer specifying the port number
+ * @since 5.2.5
+ */
+ int getServerPort();
}