[Fixes #1183] Response uses chunked encoding when returning a string

/cc: @harshgMSFT @Tratcher @yishaigalatzer 

Just FYI...before my current changes following was the behavior when a string data was returned:
- Helios : chunked response
- WebListener : non-chunked response
Bad idea for large strings. Just repeat the same pattern we have elsewhere

-----Original Message-----
From: "Kiran Challa" <notifications@github.com>
Sent: ‎9/‎26/‎2014 9:35 AM
To: "aspnet/Mvc" <Mvc@noreply.github.com>
Cc: "Yishai Galatzer" <yishai_galatzer@yahoo.com>
Subject: Re: [Mvc] [Fixes #1183] Response uses chunked encoding when returninga string (#1187)

In src/Microsoft.AspNet.Mvc.Core/Formatters/TextPlainFormatter.cs:
> @@ -51,10 +51,13 @@ public override bool CanWriteResult(OutputFormatterContext context, MediaTypeHea
>              }
>  
>              var response = context.ActionContext.HttpContext.Response;
> -            using (var writer = new StreamWriter(response.Body, context.SelectedEncoding, 1024, leaveOpen: true))
> -            {
> -                await writer.WriteAsync(valueAsString);
> -            }
> +
> +            // since we can calculate the length, set the Content-Length header
> +            // to avoid the response being sent out as chunked
> +            byte[] bytes = context.SelectedEncoding.GetBytes(valueAsString);
I agree!
—
Reply to this email directly or view it on GitHub.=