hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r408474 - /jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
Date Sun, 21 May 2006 19:53:22 GMT
Author: olegk
Date: Sun May 21 12:53:22 2006
New Revision: 408474

URL: http://svn.apache.org/viewvc?rev=408474&view=rev
Log:
Added CLI option to add an arbitrary header line(s)

Modified:
    jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java

Modified: jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java?rev=408474&r1=408473&r2=408474&view=diff
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/src/contrib/org/apache/http/contrib/benchmark/HttpBenchmark.java
Sun May 21 12:53:22 2006
@@ -117,9 +117,16 @@
         Topt.setRequired(false);
         Topt.setArgName("content-type");
 
-        Option vopt = new Option("v", true, "Set verbosity level - 4 and above prints " +
-                "information on headers, 3 and above prints response codes (404, 200, " +
-                "etc.), 2 and above prints warnings and info.");
+        Option Hopt = new Option("H", true, "Add arbitrary header line, " +
+                "eg. 'Accept-Encoding: gzip' inserted after all normal " +
+                "header lines. (repeatable)");
+        Hopt.setRequired(false);
+        Hopt.setArgName("header");
+
+        Option vopt = new Option("v", true, "Set verbosity level - 4 and above " +
+                "prints response content, 3 and above prints " +
+                "information on headers, 2 and above prints response codes (404, 200, " +
+                "etc.), 1 and above prints warnings and info.");
         vopt.setRequired(false);
         vopt.setArgName("verbosity");
 
@@ -133,6 +140,7 @@
         options.addOption(popt);
         options.addOption(Topt);
         options.addOption(vopt);
+        options.addOption(Hopt);
         options.addOption(hopt);
 
         if (args.length == 0) {
@@ -176,7 +184,7 @@
                 System.exit(-1);
             }
         }
-        
+
         args = cmd.getArgs();
         if (args.length != 1) {
             showUsage(options);
@@ -226,6 +234,20 @@
         }
         if (!keepAlive) {
             request.addHeader(new Header(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE));
+        }
+
+        if(cmd.hasOption('H')) {
+            String[] strs = cmd.getOptionValues('H');
+            for (int i = 0; i < strs.length; i++) {
+                String s = strs[i];
+                int pos = s.indexOf(':');
+                if (pos != -1) {
+                    Header header = new Header(
+                            s.substring(0, pos).trim(),
+                            s.substring(pos + 1));
+                    request.addHeader(header);
+                }
+            }
         }
         
         // Prepare request executor



Mime
View raw message