vtest "dual shared client HTTP transactions"

server s1 {
	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 {
	rxreq
	expect req.method == GET
	expect req.proto == HTTP/1.1
	expect req.url == "/"
	txresp
}

server s1 -start
server s2 -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 c1 -run

client c1 -connect ${s2_sock} {
	txreq
	rxresp
	expect resp.proto == HTTP/1.1
	expect resp.status == 200
	expect resp.reason == OK
}

client c1 -run

server s1 -wait
server s2 -wait

# The same tests with unix domain sockets
server s3 -listen "${tmpdir}/s3.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 s4 -listen "${tmpdir}/s4.sock" {
	rxreq
	expect req.method == GET
	expect req.proto == HTTP/1.1
	expect req.url == "/"
	txresp
}

server s3 -start
server s4 -start

client c2 -connect ${s3_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 -run

client c2 -connect ${s4_sock} {
	txreq
	rxresp
	expect resp.proto == HTTP/1.1
	expect resp.status == 200
	expect resp.reason == OK
}

client c2 -run

server s3 -wait
server s4 -wait
