]> Cypherpunks repositories - gostls13.git/commit
net/http/httputil: make TestDumpRequest idempotent
authorEmmanuel T Odeke <emmanuel@orijtech.com>
Sun, 9 Dec 2018 07:32:15 +0000 (23:32 -0800)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Wed, 13 Feb 2019 16:58:53 +0000 (16:58 +0000)
commitb690d7e513737769f6eed7cc53ca088517771547
tree6775fb860c2000be9b47b8723a63d7fcea942c0a
parentaf8f4062c24cb36af4dc24fbaffd23aa7f7bde36
net/http/httputil: make TestDumpRequest idempotent

TestDumpRequest was failing with -count=2 or more
because for test cases that involved mustReadRequest,
the body was created as a *bufio.Reader. DumpRequest
and DumpRequestOut would then read the body until EOF
and would close it after use.
However, on re-runs of the test, the body would
be terminally exhausted and result in an unexpected
error "http: invalid Read on closed Body".

The update to the test cases adds an extra field "GetReq"
which allows us to construct requests per run of the tests
and hence make the test indefinitely re-runnable/idempotent.
"Req" or "GetReq" are mutually exclusive: either one of them
can be set or nil, but not both.

Fixes #26858

Change-Id: Ice3083dac1aa3249da4afc7075cd984eb159530d
Reviewed-on: https://go-review.googlesource.com/c/153377
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/httputil/dump_test.go