vtest "dual shared server HTTP transactions"

server s1 -repeat 2 {
	rxreq
	expect req.method == PUT
	expect req.proto == HTTP/1.0
	expect req.url == "/foo"
	txresp -proto HTTP/1.2 -status 201 -reason Foo
}

server s1 -start

client c1 -connect ${s1_sock} {
	txreq -req PUT -proto HTTP/1.0 -url /foo
	rxresp
	expect resp.proto == HTTP/1.2
	expect resp.status == 201
	expect resp.reason == Foo
}

client c2 -connect ${s1_sock} {
	txreq -req PUT -proto HTTP/1.0 -url /foo
	rxresp
	expect resp.proto == HTTP/1.2
	expect resp.status == 201
	expect resp.reason == Foo
}

client c1 -start
client c2 -start

client c1 -wait
client c2 -wait

server s1 -wait

# The same tests with Unix domain sockets
server s2 -repeat 2 -listen "${tmpdir}/s2.sock" {
	rxreq
	expect req.method == PUT
	expect req.proto == HTTP/1.0
	expect req.url == "/foo"
	txresp -proto HTTP/1.2 -status 201 -reason Foo
}

server s2 -start

client c3 -connect ${s2_sock} {
	txreq -req PUT -proto HTTP/1.0 -url /foo
	rxresp
	expect resp.proto == HTTP/1.2
	expect resp.status == 201
	expect resp.reason == Foo
}

client c4 -connect ${s2_sock} {
	txreq -req PUT -proto HTTP/1.0 -url /foo
	rxresp
	expect resp.proto == HTTP/1.2
	expect resp.status == 201
	expect resp.reason == Foo
}

client c3 -start
client c4 -start

client c3 -wait
client c4 -wait

server s2 -wait
