Question: should there be support to write request/response content that isn't text ?
Is the feature request related to a problem
I was using this library and one of my HTTP requests returns a Zip file. When I looked at the verified file created I noticed that for the Zip response there was no response body captured.
Checking the code I noticed that the Verify.Http will not write to the verified file anything if the request/response content is not Text.
I was wondering if you thought it would be a good idea to lift this restriction and allow more than just text to be captured in the verified file ?
Describe the solution
If the body is not considered text I was thinking that perhaps this could be implemented by writing a base64 encoding of the bytes from the HttpContent ?
Additional context
-
I understand that the contents of the
verifiedfile wouldn't be human readable so it's already questionable if this brings enough value. For instance, if there's a diff how would you know if you actually want to take the diff or not when looking at a base64 value? I think here the answer is you wouldn't know, the fact that there is a diff in this scenario would just alert you to the fact that something changed and you would have to check in some other way whether you want to take the diff or not. -
The size of the file
verifiedfile could also be something to be aware of. If theverifiedfile now contained a base64 encoding of the bytes from theHttpContentthen the size of the file could easily become significantly large. If this is an issue I believe that perhaps by default writing anything other than text could be disabled and an option to toggle it on in case the user wants to. Going one step further, there could also be an option to set a limit for theHttpContentto be recorded so that if for instance theContent-Lengthheader or the length of the resulting base64 string is over X amount then thatHttpContentwould not be written to theverifiedfile. -
Also scrubbers wouldn't work when recording
HttpContentthat isn't text. So for scenarios where theHttpContentchanges per test run this wouldn't be useful. But shouldn't also create a problem to users if it's something that can be toggled on/off.
What are your thoughts on this matter?
yes there should be. i would accept a PR