Verify.Http icon indicating copy to clipboard operation
Verify.Http copied to clipboard

Question: should there be support to write request/response content that isn't text ?

Open edumserrano opened this issue 3 years ago • 1 comments

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

  1. I understand that the contents of the verified file 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.

  2. The size of the file verified file could also be something to be aware of. If the verified file now contained a base64 encoding of the bytes from the HttpContent then 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 the HttpContent to be recorded so that if for instance the Content-Length header or the length of the resulting base64 string is over X amount then that HttpContent would not be written to the verified file.

  3. Also scrubbers wouldn't work when recording HttpContent that isn't text. So for scenarios where the HttpContent changes 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?

edumserrano avatar Sep 14 '22 23:09 edumserrano

yes there should be. i would accept a PR

SimonCropp avatar Apr 30 '24 11:04 SimonCropp