1[Scripts]
2httest is script based. The following script examples can be but into a scripte i.e. sample.htt and can be called like
3
4.nf
5httest sample.htt
6
7[Simple Script]
8Get a page and do expect return code 200 OK.
9
10.nf
11CLIENT
12_REQ www.google.ch 80
13__GET /search?q=apache HTTP/1.1
14__Host: www.google.ch
15__
16_EXPECT headers "HTTP/1.1 200 OK"
17_WAIT
18END
19
20[Cut and past Script]
21Cut and past from a HTTP stream, i.e we cut the apache host to access it in the second request.
22
23.nf
24CLIENT
25_REQ www.google.ch 80
26__GET /search?q=apache HTTP/1.1
27__Host: www.google.ch
28__
29_MATCH body '\\<a href="http://([^\\/]*)/" class=l\\>Welcome! - The \\<em\\>Apache\\</em\\> HTTP Server Project' APACHE_HOST
30_WAIT
31
32_REQ $APACHE_HOST 80
33__GET / HTTP/1.1
34__Host: $APACHE_HOST
35__
36_WAIT
37END
38
39[Client Server Script]
40We can hold client and server in the same host. Actually multiple client and multiple server.
41Very useful to test forward or reverse proxies. Or a webapplication which communicat itself with third party servers i.e. mail server.
42
43This is a very basic selfcontained test you can run on any maschine.
44
45.nf
46CLIENT
47_REQ localhost 8080
48__GET /foo HTTP/1.1
49__Host: localhost
50__
51_WAIT
52END
53
54SERVER 8080
55_RES
56_EXPECT "/foo"
57_WAIT
58__HTTP/1.1 200 OK
59__Content-Length: AUTO
60__
61__Hello World
62END
63
64[SSL Script]
65Of course SSL do also work with httest, just put "SSL:" before port.
66
67.nf
68CLIENT
69_REQ localhost SSL:8080
70__GET /foo HTTP/1.1
71__Host: localhost
72__
73_WAIT
74END
75
76SERVER SSL:8080
77_RES
78_EXPECT "/foo"
79_WAIT
80__HTTP/1.1 200 OK
81__Content-Length: AUTO
82__
83__Hello World
84END
85
86
87