001/* 002 * ==================================================================== 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 * ==================================================================== 020 * 021 * This software consists of voluntary contributions made by many 022 * individuals on behalf of the Apache Software Foundation. For more 023 * information on the Apache Software Foundation, please see 024 * <http://www.apache.org/>. 025 * 026 */ 027package org.apache.http.benchmark; 028 029import java.io.File; 030import java.net.URL; 031 032public class Config { 033 034 private URL url; 035 private int requests; 036 private int threads; 037 private boolean keepAlive; 038 private int verbosity; 039 private boolean headInsteadOfGet; 040 private boolean useHttp1_0; 041 private String contentType; 042 private String[] headers; 043 private int socketTimeout; 044 private String method = "GET"; 045 private boolean useChunking; 046 private boolean useExpectContinue; 047 private boolean useAcceptGZip; 048 private File payloadFile = null; 049 private String payloadText = null; 050 private String soapAction = null; 051 052 private boolean disableSSLVerification = true; 053 private String trustStorePath = null; 054 private String identityStorePath = null; 055 private String trustStorePassword = null; 056 private String identityStorePassword = null; 057 058 public Config() { 059 super(); 060 this.url = null; 061 this.requests = 1; 062 this.threads = 1; 063 this.keepAlive = false; 064 this.verbosity = 0; 065 this.headInsteadOfGet = false; 066 this.useHttp1_0 = false; 067 this.payloadFile = null; 068 this.payloadText = null; 069 this.contentType = null; 070 this.headers = null; 071 this.socketTimeout = 60000; 072 } 073 074 public URL getUrl() { 075 return url; 076 } 077 078 public void setUrl(final URL url) { 079 this.url = url; 080 } 081 082 public int getRequests() { 083 return requests; 084 } 085 086 public void setRequests(final int requests) { 087 this.requests = requests; 088 } 089 090 public int getThreads() { 091 return threads; 092 } 093 094 public void setThreads(final int threads) { 095 this.threads = threads; 096 } 097 098 public boolean isKeepAlive() { 099 return keepAlive; 100 } 101 102 public void setKeepAlive(final boolean keepAlive) { 103 this.keepAlive = keepAlive; 104 } 105 106 public int getVerbosity() { 107 return verbosity; 108 } 109 110 public void setVerbosity(final int verbosity) { 111 this.verbosity = verbosity; 112 } 113 114 public boolean isHeadInsteadOfGet() { 115 return headInsteadOfGet; 116 } 117 118 public void setHeadInsteadOfGet(final boolean headInsteadOfGet) { 119 this.headInsteadOfGet = headInsteadOfGet; 120 this.method = "HEAD"; 121 } 122 123 public boolean isUseHttp1_0() { 124 return useHttp1_0; 125 } 126 127 public void setUseHttp1_0(final boolean useHttp1_0) { 128 this.useHttp1_0 = useHttp1_0; 129 } 130 131 public File getPayloadFile() { 132 return payloadFile; 133 } 134 135 public void setPayloadFile(final File payloadFile) { 136 this.payloadFile = payloadFile; 137 } 138 139 public String getContentType() { 140 return contentType; 141 } 142 143 public void setContentType(final String contentType) { 144 this.contentType = contentType; 145 } 146 147 public String[] getHeaders() { 148 return headers; 149 } 150 151 public void setHeaders(final String[] headers) { 152 this.headers = headers; 153 } 154 155 public int getSocketTimeout() { 156 return socketTimeout; 157 } 158 159 public void setSocketTimeout(final int socketTimeout) { 160 this.socketTimeout = socketTimeout; 161 } 162 163 public void setMethod(final String method) { 164 this.method = method; 165 } 166 167 public void setUseChunking(final boolean useChunking) { 168 this.useChunking = useChunking; 169 } 170 171 public void setUseExpectContinue(final boolean useExpectContinue) { 172 this.useExpectContinue = useExpectContinue; 173 } 174 175 public void setUseAcceptGZip(final boolean useAcceptGZip) { 176 this.useAcceptGZip = useAcceptGZip; 177 } 178 179 public String getMethod() { 180 return method; 181 } 182 183 public boolean isUseChunking() { 184 return useChunking; 185 } 186 187 public boolean isUseExpectContinue() { 188 return useExpectContinue; 189 } 190 191 public boolean isUseAcceptGZip() { 192 return useAcceptGZip; 193 } 194 195 public String getPayloadText() { 196 return payloadText; 197 } 198 199 public String getSoapAction() { 200 return soapAction; 201 } 202 203 public boolean isDisableSSLVerification() { 204 return disableSSLVerification; 205 } 206 207 public String getTrustStorePath() { 208 return trustStorePath; 209 } 210 211 public String getIdentityStorePath() { 212 return identityStorePath; 213 } 214 215 public String getTrustStorePassword() { 216 return trustStorePassword; 217 } 218 219 public String getIdentityStorePassword() { 220 return identityStorePassword; 221 } 222 223 public void setPayloadText(final String payloadText) { 224 this.payloadText = payloadText; 225 } 226 227 public void setSoapAction(final String soapAction) { 228 this.soapAction = soapAction; 229 } 230 231 public void setDisableSSLVerification(final boolean disableSSLVerification) { 232 this.disableSSLVerification = disableSSLVerification; 233 } 234 235 public void setTrustStorePath(final String trustStorePath) { 236 this.trustStorePath = trustStorePath; 237 } 238 239 public void setIdentityStorePath(final String identityStorePath) { 240 this.identityStorePath = identityStorePath; 241 } 242 243 public void setTrustStorePassword(final String trustStorePassword) { 244 this.trustStorePassword = trustStorePassword; 245 } 246 247 public void setIdentityStorePassword(final String identityStorePassword) { 248 this.identityStorePassword = identityStorePassword; 249 } 250 251 public Config copy() { 252 final Config copy = new Config(); 253 copy.url = this.url; 254 copy.requests = this.requests; 255 copy.threads = this.threads; 256 copy.keepAlive = this.keepAlive; 257 copy.verbosity = this.verbosity; 258 copy.headInsteadOfGet = this.headInsteadOfGet; 259 copy.useHttp1_0 = this.useHttp1_0; 260 copy.contentType = this.contentType; 261 copy.headers = this.headers; 262 copy.socketTimeout = this.socketTimeout; 263 copy.method = this.method; 264 copy.useChunking = this.useChunking; 265 copy.useExpectContinue = this.useExpectContinue; 266 copy.useAcceptGZip = this.useAcceptGZip; 267 copy.payloadFile = this.payloadFile; 268 copy.payloadText = this.payloadText; 269 copy.soapAction = this.soapAction; 270 271 copy.disableSSLVerification = this.disableSSLVerification; 272 copy.trustStorePath = this.trustStorePath; 273 copy.identityStorePath = this.identityStorePath; 274 copy.trustStorePassword = this.trustStorePassword; 275 copy.identityStorePassword = this.identityStorePassword; 276 return copy; 277 } 278 279}