List of usage examples for org.apache.http.contrib.benchmark DefaultHeader DefaultHeader
public DefaultHeader(final String name, final String value)
From source file:org.apache.http.contrib.benchmark.HttpBenchmark.java
private void prepare() { // prepare http params params = getHttpParams(socketTimeout, useHttp1_0); host = new HttpHost(url.getHost(), url.getPort(), url.getProtocol()); // Prepare requests for each thread request = new HttpRequest[threads]; if (postFile != null) { FileEntity entity = new FileEntity(postFile, contentType); contentLength = entity.getContentLength(); if (postFile.length() > 100000) { entity.setChunked(true);//from w w w . ja va 2s. c om } for (int i = 0; i < threads; i++) { BasicHttpEntityEnclosingRequest httppost = new BasicHttpEntityEnclosingRequest("POST", url.getPath()); httppost.setEntity(entity); request[i] = httppost; } } else if (doHeadInsteadOfGet) { for (int i = 0; i < threads; i++) { request[i] = new BasicHttpRequest("HEAD", url.getPath()); } } else { for (int i = 0; i < threads; i++) { request[i] = new BasicHttpRequest("GET", url.getPath()); } } if (!keepAlive) { for (int i = 0; i < threads; i++) { request[i].addHeader(new DefaultHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_CLOSE)); } } if (headers != null) { for (int i = 0; i < headers.length; i++) { String s = headers[i]; int pos = s.indexOf(':'); if (pos != -1) { Header header = new DefaultHeader(s.substring(0, pos).trim(), s.substring(pos + 1)); for (int j = 0; j < threads; j++) { request[j].addHeader(header); } } } } }