Skip to content

Instantly share code, notes, and snippets.

@Fonsan
Created November 30, 2012 11:40
Show Gist options
  • Save Fonsan/4175300 to your computer and use it in GitHub Desktop.
Save Fonsan/4175300 to your computer and use it in GitHub Desktop.
Keepalive tester MIT license
#!/bin/sh
NORMAL_GET='GET / HTTP/1.1\nHost: ec2-54-246-3-50.eu-west-1.compute.amazonaws.com\n'
KEEPALIVE_GET='GET / HTTP/1.1\nHost: ec2-54-246-3-50.eu-west-1.compute.amazonaws.com\nConnection: keep-alive\n'
HTTP_SERVER='ec2-54-246-3-50.eu-west-1.compute.amazonaws.com'
HTTP_SERVER_PORT=80
echo "Normal get\n"
time echo $NORMAL_GET | nc $HTTP_SERVER $HTTP_SERVER_PORT | cat
echo "\nkeep-alive get\n"
time sh -c "echo \"$KEEPALIVE_GET\"; sleep 70; echo \"$KEEPALIVE_GET\"" | nc $HTTP_SERVER $HTTP_SERVER_PORT | cat
$ sh keepalive.sh
Normal get
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 30 Nov 2012 11:38:26 GMT
Content-Type: text/plain
Content-Length: 2
Connection: keep-alive
ok
real 0m0.506s
user 0m0.002s
sys 0m0.003s
keep-alive get
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 30 Nov 2012 11:38:26 GMT
Content-Type: text/plain
Content-Length: 2
Connection: keep-alive
okHTTP/1.1 200 OK
Server: nginx
Date: Fri, 30 Nov 2012 11:39:36 GMT
Content-Type: text/plain
Content-Length: 2
Connection: keep-alive
ok
real 1m10.050s
user 0m0.004s
sys 0m0.005s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment