CefSharp.ResourceHandler.GetResponse C# (CSharp) Method

GetResponse() public method

Populate the response stream, response length. When this method is called the response should be fully populated with data. It is possible to redirect to another url at this point in time. NOTE: It's no longer manditory to implement this method, you can simply populate the properties of this instance and they will be set by the default implementation.
public GetResponse ( IResponse response, long &responseLength, string &redirectUrl ) : Stream
response IResponse The response object used to set Headers, StatusCode, etc
responseLength long length of the response
redirectUrl string If set the request will be redirect to specified Url
return Stream
        public virtual Stream GetResponse(IResponse response, out long responseLength, out string redirectUrl)
        {
            redirectUrl = null;
            responseLength = -1;

            response.MimeType = MimeType;
            response.StatusCode = StatusCode;
            response.StatusText = StatusText;
            response.ResponseHeaders = Headers;

            if(ResponseLength.HasValue)
            {
                responseLength = ResponseLength.Value;
            }
            else
            {
                //If no ResponseLength provided then attempt to infer the length
                var memoryStream = Stream as MemoryStream;
                if (memoryStream != null)
                {
                    responseLength = memoryStream.Length;
                }
            }

            return Stream;
        }