Index: support/ab.c =================================================================== --- support/ab.c (revision 808959) +++ support/ab.c (working copy) @@ -763,8 +763,10 @@ if (keepalive) printf("Keep-Alive requests: %d\n", doneka); printf("Total transferred: %" APR_INT64_T_FMT " bytes\n", totalread); - if (posting > 0) + if (posting == 1) printf("Total POSTed: %" APR_INT64_T_FMT "\n", totalposted); + if (posting == 2) + printf("Total PUT: %" APR_INT64_T_FMT "\n", totalposted); printf("HTML transferred: %" APR_INT64_T_FMT " bytes\n", totalbread); /* avoid divide by zero */ @@ -1048,10 +1050,14 @@ printf("Total transferred:" "%" APR_INT64_T_FMT " bytes\n", trstring, tdstring, tdstring, totalread); - if (posting > 0) + if (posting == 1) printf("Total POSTed:" "%" APR_INT64_T_FMT "\n", trstring, tdstring, tdstring, totalposted); + if (posting == 2) + printf("Total PUT:" + "%" APR_INT64_T_FMT "\n", + trstring, tdstring, tdstring, totalposted); printf("HTML transferred:" "%" APR_INT64_T_FMT " bytes\n", trstring, tdstring, tdstring, totalbread); @@ -1606,12 +1612,13 @@ } else { snprintf_res = apr_snprintf(request, sizeof(_request), - "POST %s HTTP/1.0\r\n" + "%s %s HTTP/1.0\r\n" "%s" "%s" "%s" "Content-length: %" APR_SIZE_T_FMT "\r\n" "Content-type: %s\r\n" "%s" "\r\n", + (posting == 1) ? "POST" : "PUT", (isproxy) ? fullurl : path, keepalive ? "Connection: Keep-Alive\r\n" : "", cookie, auth, @@ -1623,14 +1630,15 @@ } if (verbosity >= 2) - printf("INFO: POST header == \n---\n%s\n---\n", request); + printf("INFO: %s header == \n---\n%s\n---\n", + (posting == 2) ? "PUT" : "POST", request); reqlen = strlen(request); /* * Combine headers and (optional) post file into one contineous buffer */ - if (posting == 1) { + if (posting >= 1) { char *buff = malloc(postlen + reqlen + 1); if (!buff) { fprintf(stderr, "error creating request buffer: out of memory\n"); @@ -1831,6 +1839,7 @@ fprintf(stderr, " -t timelimit Seconds to max. wait for responses\n"); fprintf(stderr, " -b windowsize Size of TCP send/receive buffer, in bytes\n"); fprintf(stderr, " -p postfile File containing data to POST. Remember also to set -T\n"); + fprintf(stderr, " -u putfile File containing data to PUT. Remember also to set -T\n"); fprintf(stderr, " -T content-type Content-type header for POSTing, eg.\n"); fprintf(stderr, " 'application/x-www-form-urlencoded'\n"); fprintf(stderr, " Default is 'text/plain'\n"); @@ -2022,7 +2031,7 @@ #endif apr_getopt_init(&opt, cntxt, argc, argv); - while ((status = apr_getopt(opt, "n:c:t:b:T:p:v:rkVhwix:y:z:C:H:P:A:g:X:de:Sq" + while ((status = apr_getopt(opt, "n:c:t:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:Sq" #ifdef USE_SSL "Z:f:" #endif @@ -2047,8 +2056,8 @@ windowsize = atoi(optarg); break; case 'i': - if (posting == 1) - err("Cannot mix POST and HEAD\n"); + if (posting > 0) + err("Cannot mix POST/PUT and HEAD\n"); posting = -1; break; case 'g': @@ -2073,6 +2082,16 @@ exit(r); } break; + case 'u': + if (posting != 0) + err("Cannot mix PUT and HEAD\n"); + if (0 == (r = open_postfile(optarg))) { + posting = 2; + } + else if (postdata) { + exit(r); + } + break; case 'r': recverrok = 1; break;