Skip to content

Commit

Permalink
fix spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored Jul 3, 2016
1 parent f7b5a65 commit 77dfb3d
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions source/_posts/using-static-content-generation-in-asp.net-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,35 @@ public class StaticGeneratorMiddleware
var buffer = new MemoryStream();
var reader = new StreamReader(buffer);
context.Response.Body = buffer;
try
{
// execute the rest of the pipeline
await _next(context);

if (context.Response?.ContentType?.Contains("text/html") == false && context.Response.StatusCode != 200)
{
await _next(context);
return;
}

EnsureDestinationFolderExist(destinationFile);

// reset the buffer and retrieve the content
buffer.Seek(0, SeekOrigin.Begin);
var responseBody = await reader.ReadToEndAsync();

// output the content to disk
await WriteBodyToDisk(responseBody, destinationFile);

// copy back our buffer to the response stream
buffer.Seek(0, SeekOrigin.Begin);
await buffer.CopyToAsync(responseStream);
}
finally
{
// Workaround for https://github.com/aspnet/KestrelHttpServer/issues/940
context.Response.Body = responseStream;
}
try
{
// execute the rest of the pipeline
await _next(context);
if (context.Response?.ContentType?.Contains("text/html") == false && context.Response.StatusCode != 200)
{
await _next(context);
return;
}
EnsureDestinationFolderExist(destinationFile);
// reset the buffer and retrieve the content
buffer.Seek(0, SeekOrigin.Begin);
var responseBody = await reader.ReadToEndAsync();
// output the content to disk
await WriteBodyToDisk(responseBody, destinationFile);
// copy back our buffer to the response stream
buffer.Seek(0, SeekOrigin.Begin);
await buffer.CopyToAsync(responseStream);
}
finally
{
// Workaround for https://github.com/aspnet/KestrelHttpServer/issues/940
context.Response.Body = responseStream;
}
}

private void EnsureDestinationFolderExist(string destinationFile)
Expand Down

0 comments on commit 77dfb3d

Please sign in to comment.