protected void writeStream(Stream s, HttpResponse response) { try { response.addHeader("Content-Length", s.Length.ToString()); SocketWriteLine(response.ToString()); s.CopyTo(stream); } catch (IOException) { } s.Close(); stream.Flush(); }
protected void writeHtmlStream(Stream s, HttpResponse response) { String html; try { byte[] codedHtml = new byte[s.Length]; s.Read(codedHtml, 0, (int)s.Length); html = Encoding.UTF8.GetString(codedHtml); foreach (KeyValuePair <string, string> kp in pageMutations) { html = html.Replace(kp.Key, kp.Value); } response.addHeader("Content-Length", html.Length.ToString()); SocketWriteLine(response.ToString()); SocketWriteText(html); } catch (IOException) { } s.Close(); stream.Flush(); }
protected void writeHtmlStream(Stream s, HttpResponse response) { String html; try { byte[] codedHtml = new byte[s.Length]; s.Read(codedHtml, 0, (int)s.Length); html = Encoding.UTF8.GetString(codedHtml); foreach (KeyValuePair<string, string> kp in pageMutations) { html = html.Replace(kp.Key, kp.Value); } response.addHeader("Content-Length", html.Length.ToString()); SocketWriteLine(response.ToString()); SocketWriteText(html); } catch (IOException) { } s.Close(); stream.Flush(); }