13

I'm trying to use ab to test my webserver, but it only supports HTTP/1.1 (reject requests that have HTTP/1.0 in the first line). The -k switch only adds a header with connection: keep-alive.

Is it possible to make ab send HTTP/1.1 request?

Wei Shi
  • 233
  • 1
  • 2
  • 6
  • Why are you rejecting 1.0 requests? Be careful with that if this is to be publicly accessible; you'll break clients coming through some proxy servers. – Shane Madden Sep 30 '11 at 04:27
  • 2
    You have two choices: modify `ab` to support HTTP 1.1, or modify your web server to support HTTP 1.0. (You can probably get away with just modify `ab` send send HTTP/1.1, but that's not ideal.) – David Schwartz Sep 30 '11 at 05:40
  • Do you mean that ab _does not_ support HTTP/1.1? The question as written doesn't make sense. – Michael Hampton Sep 22 '20 at 10:56

2 Answers2

5

how about using Siege, it is as easy to use as ab, but it supports HTTP/1.1:

http://www.joedog.org/index/siege-home

2

A way found in CMU's 15-441:

perl -pi -e 's/HTTP\/1.0/HTTP\/1.1/g' /usr/bin/ab

Hacky, but it works! :D

ch271828n
  • 133
  • 5
  • A warning: This will modify the executable `/usr/bin/ab`! This must be run as root, it might trigger intrusion detection systems, and it must be repeated after every update of the package `apache2-utils`! – Gerald Schneider Sep 22 '20 at 08:56
  • @GeraldSchneider Of course it has lots of drawbacks. It comes from the official code in CMU's course, so I share it here (9 years after the question :) ) – ch271828n Sep 22 '20 at 13:40
  • 2
    This is beautiful. Here's my version, which has less requirements and doesn't modify the original binary: `sed 's|HTTP/1.0|HTTP/1.1|g' /usr/bin/ab >ab-http11` – likebike Oct 29 '20 at 23:03