You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2013/11/10 15:25:02 UTC

svn commit: r1540476 - /jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java

Author: pmouawad
Date: Sun Nov 10 14:25:02 2013
New Revision: 1540476

URL: http://svn.apache.org/r1540476
Log:
Use constants

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java?rev=1540476&r1=1540475&r2=1540476&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/ConversionUtils.java Sun Nov 10 14:25:02 2013
@@ -48,6 +48,7 @@ public class ConversionUtils {
     private static final String DOTDOT = "..";
     private static final String SLASH = "/";
     private static final String COLONSLASHSLASH = "://";
+    private static final String COLON = ":";
 
     /**
      * Extract the encoding (charset) from the Content-Type,
@@ -275,12 +276,12 @@ public class ConversionUtils {
             String redirectLocation) {
         StringBuilder builder = new StringBuilder();
         builder.append(lastUrl.getProtocol())
-            .append("://")
+            .append(COLONSLASHSLASH)
             .append(lastUrl.getHost());
         if(lastUrl.getPort()!= -1) {
-            builder.append(":").append(lastUrl.getPort());
+            builder.append(COLON).append(lastUrl.getPort());
         }
-        if(redirectLocation.startsWith("/")) {
+        if(redirectLocation.startsWith(SLASH)) {
             // A relative reference that begins with a single slash 
             // character is termed an absolute-path reference
             builder.append(redirectLocation);
@@ -293,7 +294,7 @@ public class ConversionUtils {
                 // If the base URI has a defined authority component and an empty
                 // path, then return a string consisting of "/" concatenated with the
                 // reference's path; otherwise,
-                builder.append("/").append(redirectLocation);
+                builder.append(SLASH).append(redirectLocation);
             } else {
                 // string consisting of the reference's path component
                 // appended to all but the last segment of the base URI's path (i.e.,
@@ -301,9 +302,9 @@ public class ConversionUtils {
                 // path, or excluding the entire base URI path if it does not contain
                 // any "/" characters).     
                 String path = lastUrl.getPath();
-                int index = path.lastIndexOf("/");
+                int index = path.lastIndexOf(SLASH);
                 if(index == -1) {
-                    builder.append("/").append(redirectLocation);
+                    builder.append(SLASH).append(redirectLocation);
                 } else {
                     builder.append(path.substring(0, index+1))
                         .append(redirectLocation);