/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/
/* ** This program is based on ZeusBench V1.0 written by Adam Twiss ** which is Copyright (c) 1996 by Zeus Technology Ltd. http://www.zeustech.net/ ** ** This software is provided "as is" and any express or implied warranties, ** including but not limited to, the implied warranties of merchantability and ** fitness for a particular purpose are disclaimed. In no event shall ** Zeus Technology Ltd. be liable for any direct, indirect, incidental, special, ** exemplary, or consequential damaged (including, but not limited to, ** procurement of substitute good or services; loss of use, data, or profits; ** or business interruption) however caused and on theory of liability. Whether ** in contract, strict liability or tort (including negligence or otherwise) ** arising in any way out of the use of this software, even if advised of the ** possibility of such damage. **
*/
/* ** HISTORY: ** - Originally written by Adam Twiss <adam@zeus.co.uk>, March 1996 ** with input from Mike Belshe <mbelshe@netscape.com> and ** Michael Campanella <campanella@stevms.enet.dec.com> ** - Enhanced by Dean Gaudet <dgaudet@apache.org>, November 1997 ** - Cleaned up by Ralf S. Engelschall <rse@apache.org>, March 1998 ** - POST and verbosity by Kurt Sussman <kls@merlot.com>, August 1998 ** - HTML table output added by David N. Welton <davidw@prosa.it>, January 1999 ** - Added Cookie, Arbitrary header and auth support. <dirkx@webweaving.org>, April 1999 ** Version 1.3d ** - Increased version number - as some of the socket/error handling has ** fundamentally changed - and will give fundamentally different results ** in situations where a server is dropping requests. Therefore you can ** no longer compare results of AB as easily. Hence the inc of the version. ** They should be closer to the truth though. Sander & <dirkx@covalent.net>, End 2000. ** - Fixed proxy functionality, added median/mean statistics, added gnuplot ** output option, added _experimental/rudimentary_ SSL support. Added ** confidence guestimators and warnings. Sander & <dirkx@covalent.net>, End 2000 ** - Fixed serious int overflow issues which would cause realistic (longer ** than a few minutes) run's to have wrong (but believable) results. Added ** trapping of connection errors which influenced measurements. ** Contributed by Sander Temme, Early 2001 ** Version 1.3e ** - Changed timeout behavior during write to work whilst the sockets ** are filling up and apr_write() does writes a few - but not all. ** This will potentially change results. <dirkx@webweaving.org>, April 2001 ** Version 2.0.36-dev ** Improvements to concurrent processing: ** - Enabled non-blocking connect()s. ** - Prevent blocking calls to apr_socket_recv() (thereby allowing AB to ** manage its entire set of socket descriptors). ** - Any error returned from apr_socket_recv() that is not EAGAIN or EOF ** is now treated as fatal. ** Contributed by Aaron Bannert, April 24, 2002 ** ** Version 2.0.36-2 ** Internalized the version string - this string is part ** of the Agent: header and the result output. ** ** Version 2.0.37-dev ** Adopted SSL code by Madhu Mathihalli <madhusudan_mathihalli@hp.com> ** [PATCH] ab with SSL support Posted Wed, 15 Aug 2001 20:55:06 GMT ** Introduces four 'if (int == value)' tests per non-ssl request. ** ** Version 2.0.40-dev ** Switched to the new abstract pollset API, allowing ab to ** take advantage of future apr_pollset_t scalability improvements. ** Contributed by Brian Pane, August 31, 2002 ** ** Version 2.3 ** SIGINT now triggers output_results(). ** Contributed by colm, March 30, 2006
**/
/* Note: this version string should start with \d+[\d\.]* and be a valid * string for an HTTP Agent: header when prefixed with 'ApacheBench/'. * It should reflect the version of AB - and not that of the apache server * it happens to accompany. And it should be updated or changed whenever * the results are no longer fundamentally comparable to the results of * a previous version of ab. Either due to a change in the logic of * ab - or to due to a change in the distribution it is compiled with * (such as an APR change in for example blocking).
*/ #define AP_AB_BASEREVISION "2.3"
/* * BUGS: * * - uses strcpy/etc. * - has various other poor buffer attacks related to the lazy parsing of * response headers from the server * - doesn't implement much of HTTP/1.x, only accepts certain forms of * responses * - (performance problem) heavy use of strstr shows up top in profile * only an issue for loopback usage
*/
#if'A' != 0x41 /* Hmmm... This source code isn't being compiled in ASCII. * In order for data that flows over the network to make * sense, we need to translate to/from ASCII.
*/ #define NOT_ASCII #endif
/* affects include files on Solaris */ #define BSD_COMP
#ifdefined(_MSC_VER) && !defined(LIBRESSL_VERSION_NUMBER) /* The following logic ensures we correctly glue FILE* within one CRT used * by the OpenSSL library build to another CRT used by the ab.exe build. * This became especially problematic with Visual Studio 2015.
*/ #include <openssl/applink.c> #endif
/* maximum number of requests on a time limited test */ #define MAX_REQUESTS (INT_MAX > 50000 ? 50000 : INT_MAX)
/* connection state * don't add enums or rearrange or otherwise change values without * visiting set_conn_state()
*/ typedefenum {
STATE_UNCONNECTED = 0,
STATE_CONNECTING, /* TCP connect initiated, but we don't * know if it worked yet
*/
STATE_CONNECTED, /* we know TCP connect completed */
STATE_READ
} connect_state_e;
#define CBUFFSIZE (8192)
struct connection {
apr_pool_t *ctx;
apr_socket_t *aprsock;
apr_pollfd_t pollfd; int state;
apr_size_t read; /* amount of bytes read */
apr_size_t bread; /* amount of body read */
apr_size_t rwrite, rwrote; /* keep pointers in what we write - across
* EAGAINs */
apr_size_t length; /* Content-Length value used for keep-alive */ char cbuff[CBUFFSIZE]; /* a buffer to store server response header */ int cbx; /* offset in cbuffer */ int keepalive; /* non-zero if a keep-alive request */ int gotheader; /* non-zero if we have the entire header in
* cbuff */
apr_time_t start, /* Start of connection */
connect, /* Connected, start writing */
endwrite, /* Request written */
beginread, /* First byte of input */
done; /* Connection closed */
int socknum; #ifdef USE_SSL
SSL *ssl; #endif
};
struct data {
apr_time_t starttime; /* start time of connection */
apr_interval_time_t waittime; /* between request and reading response */
apr_interval_time_t ctime; /* time to connect */
apr_interval_time_t time; /* time for connection */
};
int verbosity = 0; /* no verbosity by default */ int recverrok = 0; /* ok to proceed after socket receive errors */ enum {NO_METH = 0, GET, HEAD, PUT, POST, CUSTOM_METHOD} method = NO_METH; constchar *method_str[] = {"bug", "GET", "HEAD", "PUT", "POST", ""}; int send_body = 0; /* non-zero if sending body with request */ int requests = 1; /* Number of requests to make */ int heartbeatres = 100; /* How often do we say we're alive */ int concurrency = 1; /* Number of multiple requests to make */ int percentile = 1; /* Show percentile served */ int nolength = 0; /* Accept variable document length */ int confidence = 1; /* Show confidence estimator and warnings */ int tlimit = 0; /* time limit in secs */ int keepalive = 0; /* try and do keepalive connections */ int windowsize = 0; /* we use the OS default window size */ char servername[1024]; /* name that server reports */ char *hostname; /* host name from URL */ constchar *host_field; /* value of "Host:" header field */ constchar *path; /* path name */ char *postdata; /* *buffer containing data from postfile */
apr_size_t postlen = 0; /* length of data to be POSTed */ char *content_type = NULL; /* content type to put in POST header */ constchar *cookie, /* optional cookie line */
*auth, /* optional (basic/uuencoded) auhentication */
*hdrs; /* optional arbitrary headers */
apr_port_t port; /* port number */ char *proxyhost = NULL; /* proxy host name */ int proxyport = 0; /* proxy port */ constchar *connecthost; constchar *myhost;
apr_port_t connectport; constchar *gnuplot; /* GNUplot file */ constchar *csvperc; /* CSV Percentile file */ constchar *fullurl; constchar *colonhost; int isproxy = 0;
apr_interval_time_t aprtimeout = apr_time_from_sec(30); /* timeout value */
/* overrides for ab-generated common headers */ constchar *opt_host; /* which optional "Host:" header specified, if any */ int opt_useragent = 0; /* was an optional "User-Agent:" header specified? */ int opt_accept = 0; /* was an optional "Accept:" header specified? */ /* * XXX - this is now a per read/write transact type of value
*/
int use_html = 0; /* use html in the report */ constchar *tablestring; constchar *trstring; constchar *tdstring;
apr_size_t doclen = 0; /* the length the document should be */
apr_int64_t totalread = 0; /* total number of bytes read */
apr_int64_t totalbread = 0; /* totoal amount of entity body read */
apr_int64_t totalposted = 0; /* total number of bytes posted, inc. headers */ int started = 0; /* number of requests started, so no excess */ int done = 0; /* number of requests we have done */ int doneka = 0; /* number of keep alive connections done */ int good = 0, bad = 0; /* number of good and bad requests */ int epipe = 0; /* number of broken pipe writes */ int err_length = 0; /* requests failed due to response length */ int err_conn = 0; /* requests failed due to connection drop */ int err_recv = 0; /* requests failed due to broken read */ int err_except = 0; /* requests failed due to exception */ int err_response = 0; /* requests with invalid or non-200 response */
#ifdef USE_SSL int is_ssl;
SSL_CTX *ssl_ctx; char *ssl_cipher = NULL; char *ssl_info = NULL; char *ssl_cert = NULL; #if OPENSSL_VERSION_NUMBER >= 0x10002000L char *ssl_tmp_key = NULL; #endif
BIO *bio_out,*bio_err; #ifdef HAVE_TLSEXT int tls_use_sni = 1; /* used by default, -I disables it */ constchar *tls_sni = NULL; /* 'opt_host' if any, 'hostname' otherwise */ #endif #endif
apr_time_t start, lasttime, stoptime;
/* global request (and its length) */ char _request[8192]; char *request = _request;
apr_size_t reqlen; int requests_initialized = 0;
/* one global throw-away buffer to read stuff into */ char buffer[8192];
/* * Similar to standard strstr() but we ignore case in this version. * Copied from ap_strcasestr().
*/ staticchar *xstrcasestr(constchar *s1, constchar *s2)
{ char *p1, *p2; if (*s2 == '\0') { /* an empty s2 */ return((char *)s1);
} while(1) { for ( ; (*s1 != '\0') && (apr_tolower(*s1) != apr_tolower(*s2)); s1++); if (*s1 == '\0') { return(NULL);
} /* found first character of s2, see if the rest matches */
p1 = (char *)s1;
p2 = (char *)s2; for (++p1, ++p2; apr_tolower(*p1) == apr_tolower(*p2); ++p1, ++p2) { if (*p1 == '\0') { /* both strings ended together */ return((char *)s1);
}
} if (*p2 == '\0') { /* second string ended, a match */ break;
} /* didn't find a match here, try starting at next character in s1 */
s1++;
} return((char *)s1);
}
/* pool abort function */ staticint abort_on_oom(int retcode)
{
fprintf(stderr, "Could not allocate memory\n"); exit(1); /* not reached */ return retcode;
}
staticvoid set_conn_state(struct connection *c, connect_state_e new_state)
{
apr_int16_t events_by_state[] = {
0, /* for STATE_UNCONNECTED */
APR_POLLOUT, /* for STATE_CONNECTING */
APR_POLLIN, /* for STATE_CONNECTED; we don't poll in this state, * so prepare for polling in the following state -- * STATE_READ
*/
APR_POLLIN /* for STATE_READ */
};
/* --------------------------------------------------------- */ /* write out request to a connection - assumes we can write * (small) request out in one go into our new socket buffer *
*/ #ifdef USE_SSL #if OPENSSL_VERSION_NUMBER >= 0x30000000L staticlong ssl_print_cb(BIO *bio, int cmd, constchar *argp,
size_t len, int argi, long argl, int ret,
size_t *processed) #else staticlong ssl_print_cb(BIO *bio, int cmd, constchar *argp, int argi, long argl, long ret) #endif
{
BIO *out; #if OPENSSL_VERSION_NUMBER >= 0x30000000L
(void)len;
(void)processed; #endif
out=(BIO *)BIO_get_callback_arg(bio); if (out == NULL) return(ret);
staticvoid ssl_state_cb(const SSL *s, int w, int r)
{ if (w & SSL_CB_ALERT) {
BIO_printf(bio_err, "SSL/TLS Alert [%s] %s:%s\n",
(w & SSL_CB_READ ? "read" : "write"),
SSL_alert_type_string_long(r),
SSL_alert_desc_string_long(r));
} elseif (w & SSL_CB_LOOP) {
BIO_printf(bio_err, "SSL/TLS State [%s] %s\n",
(SSL_in_connect_init((SSL*)s) ? "connect" : "-"),
SSL_state_string_long(s));
} elseif (w & (SSL_CB_HANDSHAKE_START|SSL_CB_HANDSHAKE_DONE)) {
BIO_printf(bio_err, "SSL/TLS Handshake [%s] %s\n",
(w & SSL_CB_HANDSHAKE_START ? "Start" : "Done"),
SSL_state_string_long(s));
}
}
#ifndef RAND_MAX #define RAND_MAX INT_MAX #endif
staticint ssl_rand_choosenum(int l, int h)
{ int i; char buf[50];
srand((unsignedint)time(NULL));
apr_snprintf(buf, sizeof(buf), "%.0f",
(((double)(rand()%RAND_MAX)/RAND_MAX)*(h-l)));
i = atoi(buf)+1; if (i < l) i = l; if (i > h) i = h; return i;
}
staticvoid ssl_rand_seed(void)
{ int n, l;
time_t t;
pid_t pid; unsignedchar stackdata[256];
/* * seed in the current time (usually just 4 bytes)
*/
t = time(NULL);
l = sizeof(time_t);
RAND_seed((unsignedchar *)&t, l);
/* * seed in the current process id (usually just 4 bytes)
*/
pid = getpid();
l = sizeof(pid_t);
RAND_seed((unsignedchar *)&pid, l);
/* * seed in some current state of the run-time stack (128 bytes)
*/
n = ssl_rand_choosenum(0, sizeof(stackdata)-128-1);
RAND_seed(stackdata+n, 128);
}
c = SSL_get_current_cipher(ssl);
BIO_printf(bio,"Cipher Suite Protocol :%s\n", SSL_CIPHER_get_version(c));
BIO_printf(bio,"Cipher Suite Name :%s\n",SSL_CIPHER_get_name(c));
bits = SSL_CIPHER_get_bits(c,&alg_bits);
BIO_printf(bio,"Cipher Suite Cipher Bits:%d (%d)\n",bits,alg_bits);
staticint compradre(struct data * a, struct data * b)
{ if ((a->ctime) < (b->ctime)) return -1; if ((a->ctime) > (b->ctime)) return +1; return 0;
}
staticint comprando(struct data * a, struct data * b)
{ if ((a->time) < (b->time)) return -1; if ((a->time) > (b->time)) return +1; return 0;
}
staticint compri(struct data * a, struct data * b)
{
apr_interval_time_t p = a->time - a->ctime;
apr_interval_time_t q = b->time - b->ctime; if (p < q) return -1; if (p > q) return +1; return 0;
}
staticint compwait(struct data * a, struct data * b)
{ if ((a->waittime) < (b->waittime)) return -1; if ((a->waittime) > (b->waittime)) return 1; return 0;
}
/* calculating the sample variance: the sum of the squared deviations, divided by n-1 */ for (i = 0; i < done; i++) { struct data *s = &stats[i]; double a;
a = ((double)s->time - meantot);
sdtot += a * a;
a = ((double)s->ctime - meancon);
sdcon += a * a;
a = ((double)s->time - (double)s->ctime - meand);
sdd += a * a;
a = ((double)s->waittime - meanwait);
sdwait += a * a;
}
/* * XXX: what is better; this hideous cast of the compradre function; or * the four warnings during compile ? dirkx just does not know and * hates both/
*/
qsort(stats, done, sizeof(struct data),
(int (*) (constvoid *, constvoid *)) compradre); if ((done > 1) && (done % 2))
mediancon = (stats[done / 2].ctime + stats[done / 2 + 1].ctime) / 2; else
mediancon = stats[done / 2].ctime;
#define SANE(what,mean,median,sd) \
{ \ double d = (double)mean - median; \ if (d < 0) d = -d; \ if (d > 2 * sd ) \
printf("ERROR: The median and mean for " what " are more than twice the standard\n" \ " deviation apart. These results are NOT reliable.\n"); \ elseif (d > sd ) \
printf("WARNING: The median and mean for " what " are not within a normal deviation\n" \ " These results are probably not that reliable.\n"); \
}
SANE("the initial connection time", meancon, mediancon, sdcon);
SANE("the processing time", meand, mediand, sdd);
SANE("the waiting time", meanwait, medianwait, sdwait);
SANE("the total time", meantot, mediantot, sdtot);
} else {
printf(" min avg max\n"); #define CONF_FMT_STRING "%5" APR_TIME_T_FMT " %5" APR_TIME_T_FMT "%5" APR_TIME_T_FMT "\n"
printf("Connect: " CONF_FMT_STRING, mincon, meancon, maxcon);
printf("Processing: " CONF_FMT_STRING, mind, meand, maxd);
printf("Waiting: " CONF_FMT_STRING, minwait, meanwait, maxwait);
printf("Total: " CONF_FMT_STRING, mintot, meantot, maxtot); #undef CONF_FMT_STRING
}
/* Sorted on total connect times */ if (percentile && (done > 1)) {
printf("\nPercentage of the requests served within a certain time (ms)\n"); for (i = 0; i < sizeof(percs) / sizeof(int); i++) { if (percs[i] <= 0)
printf(" 0%% <0> (never)\n"); elseif (percs[i] >= 100)
printf(" 100%% %5" APR_TIME_T_FMT " (longest request)\n",
ap_round_ms(stats[done - 1].time)); else
printf(" %d%% %5" APR_TIME_T_FMT "\n", percs[i],
ap_round_ms(stats[(unsignedlong)done * percs[i] / 100].time));
}
} if (csvperc) {
FILE *out = fopen(csvperc, "w"); if (!out) {
perror("Cannot open CSV output file"); exit(1);
}
fprintf(out, """Percentage served"",""Time in ms""\n"); for (i = 0; i <= 100; i++) { double t; if (i == 0)
t = ap_double_ms(stats[0].time); elseif (i == 100)
t = ap_double_ms(stats[done - 1].time); else
t = ap_double_ms(stats[(unsignedlong) (0.5 + (double)done * i / 100.0)].time);
fprintf(out, "%d,%.3f\n", i, t);
}
fclose(out);
} if (gnuplot) {
FILE *out = fopen(gnuplot, "w"); char tmstring[APR_CTIME_LEN]; if (!out) {
perror("Cannot open gnuplot output file"); exit(1);
}
fprintf(out, "starttime\tseconds\tctime\tdtime\tttime\twait\n"); for (i = 0; i < done; i++) {
(void) apr_ctime(tmstring, stats[i].starttime);
fprintf(out, "%s\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\t%" APR_TIME_T_FMT "\n", tmstring,
apr_time_sec(stats[i].starttime),
ap_round_ms(stats[i].ctime),
ap_round_ms(stats[i].time - stats[i].ctime),
ap_round_ms(stats[i].time),
ap_round_ms(stats[i].waittime));
}
fclose(out);
}
}
staticvoid read_connection(struct connection * c)
{
apr_size_t r;
apr_status_t status; char *part; char respcode[4]; /* 3 digits and null */ int i;
r = sizeof(buffer);
read_more: #ifdef USE_SSL if (c->ssl) {
status = SSL_read(c->ssl, buffer, r); if (status <= 0) { int scode = SSL_get_error(c->ssl, status);
if (scode == SSL_ERROR_ZERO_RETURN) { /* connection closed cleanly: */
good++;
close_connection(c);
} elseif (scode == SSL_ERROR_SYSCALL
&& status == 0
&& c->read != 0) { /* connection closed, but in violation of the protocol, after * some data has already been read; this commonly happens, so * let the length check catch any response errors
*/
good++;
close_connection(c);
} elseif (scode == SSL_ERROR_SYSCALL
&& c->read == 0
&& destsa->next
&& c->state == STATE_CONNECTING
&& good == 0) { return;
} elseif (scode == SSL_ERROR_WANT_READ) {
set_polled_events(c, APR_POLLIN);
} elseif (scode == SSL_ERROR_WANT_WRITE) {
set_polled_events(c, APR_POLLOUT);
} else { /* some fatal error: */
c->read = 0;
BIO_printf(bio_err, "SSL read failed (%d) - closing connection\n", scode);
ERR_print_errors(bio_err);
close_connection(c);
} return;
}
r = status;
} else #endif
{
status = apr_socket_recv(c->aprsock, buffer, &r); if (APR_STATUS_IS_EAGAIN(status)) return; elseif (r == 0 && APR_STATUS_IS_EOF(status)) {
good++;
close_connection(c); return;
} /* catch legitimate fatal apr_socket_recv errors */ elseif (status != APR_SUCCESS) { if (recverrok) {
err_recv++;
bad++;
close_connection(c); if (verbosity >= 1) { char buf[120];
fprintf(stderr,"%s: %s (%d)\n", "apr_socket_recv", apr_strerror(status, buf, sizeof buf), status);
} return;
} elseif (destsa->next && c->state == STATE_CONNECTING
&& c->read == 0 && good == 0) { return;
} else {
err_recv++;
apr_err("apr_socket_recv", status);
}
}
}
if (!c->gotheader) { char *s; int l = 4;
apr_size_t space = CBUFFSIZE - c->cbx - 1; /* -1 allows for \0 term */ int tocopy = (space < r) ? space : r; #ifdef NOT_ASCII
apr_size_t inbytes_left = space, outbytes_left = space;
status = apr_xlate_conv_buffer(from_ascii, buffer, &inbytes_left,
c->cbuff + c->cbx, &outbytes_left); if (status || inbytes_left || outbytes_left) {
fprintf(stderr, "only simple translation is supported (%d/%" APR_SIZE_T_FMT "/%" APR_SIZE_T_FMT ")\n", status, inbytes_left, outbytes_left); exit(1);
} #else
memcpy(c->cbuff + c->cbx, buffer, space); #endif/* NOT_ASCII */
c->cbx += tocopy;
space -= tocopy;
c->cbuff[c->cbx] = 0; /* terminate for benefit of strstr */ if (verbosity >= 2) {
printf("LOG: header received:\n%s\n", c->cbuff);
}
s = strstr(c->cbuff, "\r\n\r\n"); /* * this next line is so that we talk to NCSA 1.5 which blatantly * breaks the http specifaction
*/ if (!s) {
s = strstr(c->cbuff, "\n\n");
l = 2;
}
if (!s) { /* read rest next time */ if (space) { return;
} else { /* header is in invalid or too big - close connection */
set_conn_state(c, STATE_UNCONNECTED);
apr_socket_close(c->aprsock);
err_response++; if (bad++ > 10) {
err("\nTest aborted after 10 failures\n\n");
}
start_connect(c);
}
} else { /* have full header */ if (!good) { /* * this is first time, extract some interesting info
*/ char *p, *q;
size_t len = 0;
p = xstrcasestr(c->cbuff, "Server:");
q = servername; if (p) {
p += 8; /* -1 to not overwrite last '\0' byte */ while (*p > 32 && len++ < sizeof(servername) - 1)
*q++ = *p++;
}
*q = 0;
} /* * XXX: this parsing isn't even remotely HTTP compliant... but in * the interest of speed it doesn't totally have to be, it just * needs to be extended to handle whatever servers folks want to * test against. -djg
*/
if (respcode[0] != '2') {
err_response++; if (verbosity >= 2)
printf("WARNING: Response code not 2xx (%s)\n", respcode);
} elseif (verbosity >= 3) {
printf("LOG: Response code = %s\n", respcode);
}
c->gotheader = 1;
*s = 0; /* terminate at end of header */ if (keepalive && xstrcasestr(c->cbuff, "Keep-Alive")) { char *cl;
c->keepalive = 1;
cl = xstrcasestr(c->cbuff, "Content-Length:"); if (cl && method != HEAD) { /* response to HEAD doesn't have entity body */
c->length = atoi(cl + 16);
} else {
c->length = 0;
}
}
c->bread += c->cbx - (s + l - c->cbuff) + r - tocopy;
totalbread += c->bread;
/* We have received the header, so we know this destination socket
* address is working, so initialize all remaining requests. */ if (!requests_initialized) { for (i = 1; i < concurrency; i++) {
con[i].socknum = i;
start_connect(&con[i]);
}
requests_initialized = 1;
}
}
} else { /* outside header, everything we have read is entity body */
c->bread += r;
totalbread += r;
} if (r == sizeof(buffer) && c->bread < c->length) { /* read was full, try more immediately (nonblocking already) */ goto read_more;
}
if (c->keepalive && (c->bread >= c->length)) { /* finished a keep-alive connection */
good++; /* save out time */ if (good == 1) { /* first time here */
doclen = c->bread;
} elseif ((c->bread != doclen) && !nolength) {
bad++;
err_length++;
} if (done < requests) { struct data *s = &stats[done++];
doneka++;
c->done = apr_time_now();
s->starttime = c->start;
s->ctime = ap_max(0, c->connect - c->start);
s->time = ap_max(0, c->done - c->start);
s->waittime = ap_max(0, c->beginread - c->endwrite); if (heartbeatres && !(done % heartbeatres)) {
fprintf(stderr, "Completed %d requests\n", done);
fflush(stderr);
}
}
c->keepalive = 0;
c->length = 0;
c->gotheader = 0;
c->cbx = 0;
c->read = c->bread = 0; /* zero connect time with keep-alive */
c->start = c->connect = lasttime = apr_time_now();
set_conn_state(c, STATE_CONNECTED);
write_request(c);
}
}
/* add default headers if necessary */ if (!opt_host) { /* Host: header not overridden, add default value to hdrs */
hdrs = apr_pstrcat(cntxt, hdrs, "Host: ", host_field, colonhost, "\r\n", NULL);
} else { /* Header overridden, no need to add, as it is already in hdrs */
}
#ifdef HAVE_TLSEXT if (is_ssl && tls_use_sni) {
apr_ipsubnet_t *ip; if (((tls_sni = opt_host) || (tls_sni = hostname)) &&
(!*tls_sni || apr_ipsubnet_create(&ip, tls_sni, NULL,
cntxt) == APR_SUCCESS)) { /* IP not allowed in TLS SNI extension */
tls_sni = NULL;
}
} #endif
if (!opt_useragent) { /* User-Agent: header not overridden, add default value to hdrs */
hdrs = apr_pstrcat(cntxt, hdrs, "User-Agent: ApacheBench/", AP_AB_BASEREVISION, "\r\n", NULL);
} else { /* Header overridden, no need to add, as it is already in hdrs */
}
if (!opt_accept) {
--> --------------------
--> maximum size reached
--> --------------------
¤ Dauer der Verarbeitung: 0.34 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.