示例#1
0
        public override async Task <byte[]> CreateResponseAsync(IHttpRequestWrapper request, byte[] requestBody, IHttpResponseWrapper response, Endpoint endpoint)
        {
            var requestInfo = new RequestInfo
            {
                RequestPath = request.Path.ToString(),
                QueryString = request.QueryString.ToString(),
                RequestBody = Encoding.UTF8.GetString(requestBody),
                Headers     = request.Headers,
                Endpoint    = endpoint
            };
            var responseBody = await GetBodyAndExecuteReplacementsAsync(requestInfo);

            SetContentType(requestInfo, response);
            SetStatusCode(requestInfo, response);

            await response.WriteAsync(responseBody, Encoding);

            return(Encoding.GetBytes(responseBody));
        }
示例#2
0
        public override async Task <byte[]> CreateResponseAsync(IHttpRequestWrapper request, byte[] requestBody, IHttpResponseWrapper response, string endpointDirectory)
        {
            var responseBody = GetBodyAndExecuteReplacements(new RequestInfo
            {
                RequestPath       = request.Path.ToString(),
                QueryString       = request.QueryString.ToString(),
                RequestBody       = Encoding.UTF8.GetString(requestBody),
                Headers           = request.Headers,
                EndpointDirectory = endpointDirectory
            });

            if (ContentType != null)
            {
                var contenttype = ContentType;
                contenttype         += $"; charset={Encoding.WebName}";
                response.ContentType = contenttype;
            }
            await response.WriteAsync(responseBody, Encoding);

            return(Encoding.GetBytes(responseBody));
        }