public async Task <bool> HandleServeLiveReloadScript(HttpContext context) { if (context.Request.Path == LiveReloadConfiguration.Current.LiveReloadScriptUrl) { context.Response.ContentType = "text/javascript"; await context.Response.WriteAsync(WebsocketScriptInjectionHelper.GetWebSocketClientJavaScript(context, true)); return(true); } return(false); }
public override void Write(byte[] buffer, int offset, int count) { if (IsHtmlResponse()) { WebsocketScriptInjectionHelper.InjectLiveReloadScriptAsync(buffer, offset, count, _context, _baseStream) .GetAwaiter() .GetResult(); } else { _baseStream?.Write(buffer, offset, count); } }
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (IsHtmlResponse()) { await WebsocketScriptInjectionHelper.InjectLiveReloadScriptAsync( buffer, offset, count, _context, _baseStream); } else { if (_baseStream != null) { await _baseStream.WriteAsync(buffer, offset, count, cancellationToken); } } }