Unplanned
Last Updated: 12 Aug 2020 08:36 by ADMIN
Eric
Created on: 06 Aug 2020 13:44
Type: Feature Request
0
Add UnencodedRequestBody and UnencodedResponseBody properties (akin to GetResponseBodyAsString but not a string) to Session

Most extensions and inspectors need to access the decompressed/unchunked body bytes to perform their function, requiring them to have an understanding of how to get those decoded bytes. To simplify this, add UnencodedRequestBody and UnencodedResponseBody properties to Session that return a byte[], for example:

            

         public byte[] UnencodedResponse() {
            if (!_HasResponseBody() || !Utilities.HasHeaders(oResponse)) return Utilities.emptyByteArray;

            if (oResponse.headers.ExistsAny(new[] { "Content-Encoding", "Transfer-Encoding" }))
            {
                arrResponse = Utilities.Dupe(mySession.responseBodyBytes);
                Utilities.utilDecodeHTTPBody(mySession.ResponseHeaders, ref arrResponse);
            }
            else
            {
                arrResponse = mySession.responseBodyBytes;
            }
         }

 

GetRequestBodyAsString and GetResponseBodyAsString can then be refactored to call these byte[] properties.

1 comment
Eric
Posted on: 06 Aug 2020 13:51

It's been a while since I've written C#. :)

These should be methods, not properties, and named GetUnencodedRequestBody and GetUnencodedResponseBody respectively.