You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/03/01 15:04:09 UTC

[tomcat] branch main updated (c28d4d7 -> c3eb91e)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from c28d4d7  Fix BZ 65921 - type sets content-type for response not request
     new 6311bcf  Fix Response#sendRedirect() if no request context exists.
     new c3eb91e  Minor fixes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/catalina/connector/Response.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/02: Fix Response#sendRedirect() if no request context exists.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 6311bcff2849b40e84976d48bd158ec7687688c7
Author: Knut Sander <kn...@mgm-sp.com>
AuthorDate: Thu Feb 24 18:40:16 2022 +0100

    Fix Response#sendRedirect() if no request context exists.
    
    If no ROOT context is defined, the context may be null in special cases, e.g. RewriteValve may use Response#sendRedirect() without any application context associated.
    In this case, the Tomcat behaviors for the context attributes useRelativeRedirects and sendRedirectBody are assumed, but without considering org.apache.catalina.STRICT_SERVLET_COMPLIANCE.
---
 java/org/apache/catalina/connector/Response.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java
index 677ae41..e83b137 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -1287,17 +1287,22 @@ public class Response implements HttpServletResponse {
 
         // Generate a temporary redirect to the specified location
         try {
+            Context context = getContext();
+            // If no ROOT context is defined, the context can be null.
+            // In this case, the default Tomcat values are assumed, but without
+            // respect to org.apache.catalina.STRICT_SERVLET_COMPLIANCE.
+            boolean reqHasContext = context == null;
             String locationUri;
             // Relative redirects require HTTP/1.1
             if (getRequest().getCoyoteRequest().getSupportsRelativeRedirects() &&
-                    getContext().getUseRelativeRedirects()) {
+                (!reqHasContext || context.getUseRelativeRedirects())) {
                 locationUri = location;
             } else {
                 locationUri = toAbsolute(location);
             }
             setStatus(status);
             setHeader("Location", locationUri);
-            if (getContext().getSendRedirectBody()) {
+            if (reqHasContext && context.getSendRedirectBody()) {
                 PrintWriter writer = getWriter();
                 writer.print(sm.getString("coyoteResponse.sendRedirect.note",
                         Escape.htmlElementContent(locationUri)));

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/02: Minor fixes

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit c3eb91ee439599f96a59cdf64dc0d6453023be78
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Mar 1 14:57:34 2022 +0000

    Minor fixes
---
 java/org/apache/catalina/connector/Response.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java
index e83b137..f3402e8 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -1290,12 +1290,12 @@ public class Response implements HttpServletResponse {
             Context context = getContext();
             // If no ROOT context is defined, the context can be null.
             // In this case, the default Tomcat values are assumed, but without
-            // respect to org.apache.catalina.STRICT_SERVLET_COMPLIANCE.
+            // reference to org.apache.catalina.STRICT_SERVLET_COMPLIANCE.
             boolean reqHasContext = context == null;
             String locationUri;
             // Relative redirects require HTTP/1.1
             if (getRequest().getCoyoteRequest().getSupportsRelativeRedirects() &&
-                (!reqHasContext || context.getUseRelativeRedirects())) {
+                    (!reqHasContext || context.getUseRelativeRedirects())) {
                 locationUri = location;
             } else {
                 locationUri = toAbsolute(location);

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org