Fix issue #673: incorrect content length reporting (#674)
Without regexp validations, the current code reads the response from the
server in order to figure out the number of bytes we received. With
regular expression validations, it's necessary to read the whole
response in order verify it if matches or not. In this case, since the
response is completely consumed, the current code is reporting a length
of 0.
Modify the code so that we can keep track of the content length in
either case: wrap the io.ReadCloser that corresponds to the response
body with another io.ReadCloser that keeps track of the number of bytes
read. After completely consuming the reponse, the wrapper is able to
report the total number of bytes read.
Add TestContentLength that checks the content lenght is reported
correctly.
Rework existing TestFailIfBodyMatchesRegexp to reduce repetiiton; add
expectations to avoid regressing issue 673.
Fixes #673
Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>