ApacheBench
view release on metacpan or search on metacpan
src/apachebench/socket_io.c view on Meta::CPAN
strcpy(ctype, "application/x-www-form-urlencoded");
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 0.1\n");
#endif
if (registry->ctypes[i]) {
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 0.1.1\n");
#endif
free(ctype);
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 0.1.2\n");
#endif
ctype = registry->ctypes[i];
}
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 1\n");
#endif
c->request = calloc(registry->buffersize[c->run], sizeof(char));
c->request_headers = calloc(registry->buffersize[c->run], sizeof(char));
if (registry->posting[i] <= 0) {
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 1.1 (GET)\n");
#endif
sprintf(c->request_headers, "%s %s HTTP/1.0\r\n"
"User-Agent: ApacheBench-Perl/%s\r\n"
"Host: %s\r\n"
"Accept: */*\r\n",
(registry->posting[i] == 0) ? "GET" : "HEAD",
registry->path[i],
registry->version,
registry->hostname[i]);
} else {
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 1.1 (POST)\n");
#endif
sprintf(c->request_headers, "POST %s HTTP/1.0\r\n"
"User-Agent: ApacheBench-Perl/%s\r\n"
"Host: %s\r\n"
"Accept: */*\r\n"
"Content-length: %d\r\n"
"Content-type: %s\r\n",
registry->path[i],
registry->version,
registry->hostname[i],
registry->postlen[i],
ctype);
}
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 2\n");
#endif
if (registry->keepalive[i])
strcat(c->request_headers, "Connection: Keep-Alive\r\n");
if (registry->cookie[c->run]) {
strcat(c->request_headers, "Cookie: ");
strcat(c->request_headers, registry->cookie[c->run]);
strcat(c->request_headers, "\r\n");
}
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 2.1: c->run %d; c->thread %d\n", c->run, c->thread);
#endif
allocate_auto_cookie_memory(registry, c);
if (registry->use_auto_cookies[c->run] && registry->auto_cookies[c->run] != NULL && registry->auto_cookies[c->run][c->thread] != NULL) {
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 2.2a: request_headers %s\n", c->request_headers);
printf("AB_DEBUG: reset_request() - stage 2.2b: auto_cookies %s\n", registry->auto_cookies[c->run][c->thread]);
#endif
strcat(c->request_headers, registry->auto_cookies[c->run][c->thread]);
}
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 2.3: c->run %d; c->thread %d\n", c->run, c->thread);
#endif
if (registry->req_headers[i]) {
strcat(c->request_headers, registry->req_headers[i]);
strcat(c->request_headers, "\r\n");
}
strcat(c->request_headers, "\r\n");
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 2.4: c->run %d; c->thread %d\n", c->run, c->thread);
#endif
strcpy(c->request, c->request_headers);
c->reqlen = strlen(c->request);
#ifdef AB_DEBUG
printf("AB_DEBUG: reset_request() - stage 3\n");
#endif
#ifdef CHARSET_EBCDIC
ebcdic2ascii(c->request, c->request, c->reqlen);
#endif /* CHARSET_EBCDIC */
return 0;
}
/* --------------------------------------------------------- */
/* setup the next request in the sequence / repetition / run to be sent
returns 1 if the next request is ready to be sent,
returns 0 if this connection is done,
sets the connection values: c->run, c->url, c->thread, and c->state,
as well as helper structures: registry->which_thread[][],
registry->ready_to_run_queue[], and registry->arranged[]
*/
static int
( run in 0.656 second using v1.01-cache-2.11-cpan-39bf76dae61 )