Skip to content

Instantly share code, notes, and snippets.

@changs
Created January 10, 2014 15:52
Show Gist options
  • Save changs/8356869 to your computer and use it in GitHub Desktop.
Save changs/8356869 to your computer and use it in GitHub Desktop.
Add to AB the ability to show response from server for every request.
diff --git a/ab.c b/ab.c
index 5a6f2a0..c1c88a5 100644
--- a/ab.c
+++ b/ab.c
@@ -262,6 +262,7 @@ struct data {
/* --------------------- GLOBALS ---------------------------- */
int verbosity = 0; /* no verbosity by default */
+int show_response = 0; /* non-zero to show server response to every request */
int recverrok = 0; /* ok to proceed after socket receive errors */
enum {NO_METH = 0, GET, HEAD, PUT, POST} method = NO_METH;
const char *method_str[] = {"bug", "GET", "HEAD", "PUT", "POST"};
@@ -1335,6 +1336,9 @@ static void read_connection(struct connection * c)
char *part;
char respcode[4]; /* 3 digits and null */
+ if (show_response) {
+ fprintf(stdout, "%s", buffer);
+ }
r = sizeof(buffer);
#ifdef USE_SSL
if (c->ssl) {
@@ -1877,6 +1881,7 @@ static void usage(const char *progname)
fprintf(stderr, " 'application/x-www-form-urlencoded'\n");
fprintf(stderr, " Default is 'text/plain'\n");
fprintf(stderr, " -v verbosity How much troubleshooting info to print\n");
+ fprintf(stderr, " -o Print out responses from the server\n");
fprintf(stderr, " -w Print out results in HTML tables\n");
fprintf(stderr, " -i Use HEAD instead of GET\n");
fprintf(stderr, " -x attributes String to insert as table attributes\n");
@@ -2068,7 +2073,7 @@ int main(int argc, const char * const argv[])
myhost = NULL; /* 0.0.0.0 or :: */
apr_getopt_init(&opt, cntxt, argc, argv);
- while ((status = apr_getopt(opt, "n:c:t:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:SqB:"
+ while ((status = apr_getopt(opt, "n:c:t:b:T:p:u:v:rkVhwoix:y:z:C:H:P:A:g:X:de:SqB:"
#ifdef USE_SSL
"Z:f:"
#endif
@@ -2133,6 +2138,9 @@ int main(int argc, const char * const argv[])
case 'v':
verbosity = atoi(opt_arg);
break;
+ case 'o':
+ show_response = 1;
+ break;
case 't':
tlimit = atoi(opt_arg);
requests = MAX_REQUESTS; /* need to size data array on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment