예제 #1
0
        /// <summary>
        /// Process and manipulate the buffer.
        /// </summary>
        /// <param name="buffer">An array of bytes. This method copies <paramref name="count"/> bytes from <paramref name="buffer"/> to the current stream.</param>
        /// <param name="offset">The zero-based byte offset in <paramref name="buffer"/> at which to begin copying bytes to the current stream.</param>
        /// <param name="count">The number of bytes to be written to the current stream.</param>
        protected override void Process(byte[] buffer, int offset, int count)
        {
            string html = Encoding.Default.GetString(buffer, offset, count);

            html = WebPageProcessor.RemoveWhitespaceFromHtml(html);

            byte[] outdata = System.Text.Encoding.Default.GetBytes(html);
            this.Sink.Write(outdata, 0, outdata.GetLength(0));
        }
예제 #2
0
        /// <summary>
        /// Process and manipulate the buffer.
        /// </summary>
        /// <param name="buffer">An array of bytes. This method copies <paramref name="count"/> bytes from <paramref name="buffer"/> to the current stream.</param>
        /// <param name="offset">The zero-based byte offset in <paramref name="buffer"/> at which to begin copying bytes to the current stream.</param>
        /// <param name="count">The number of bytes to be written to the current stream.</param>
        protected override void Process(byte[] buffer, int offset, int count)
        {
            string html = Encoding.Default.GetString(buffer, offset, count);

            var matches = regex.Matches(html);

            foreach (Match match in matches)
            {
                string style = match.Groups[1].Value;
                html = html.Replace(style, WebPageProcessor.RemoveWhiteSpaceFromStylesheets(style));
            }

            byte[] outdata = System.Text.Encoding.Default.GetBytes(html);
            this.Sink.Write(outdata, 0, outdata.GetLength(0));
        }
예제 #3
0
        /// <summary>
        /// Process and manipulate the buffer.
        /// </summary>
        /// <param name="buffer">An array of bytes. This method copies <paramref name="count"/> bytes from <paramref name="buffer"/> to the current stream.</param>
        /// <param name="offset">The zero-based byte offset in <paramref name="buffer"/> at which to begin copying bytes to the current stream.</param>
        /// <param name="count">The number of bytes to be written to the current stream.</param>
        protected override void Process(byte[] buffer, int offset, int count)
        {
            if (this.context.Items["sharepresence.conditionalget"] == null)
            {
                try
                {
                    lock (syncRoot)
                    {
                        string etag = Convert.ToBase64String(hashAlgorithm.ComputeHash(buffer, offset, count));
                        WebPageProcessor.SetConditionalGetHeaders(etag, this.context);
                        this.context.Items.Add("sharepresence.conditionalget", 1);
                    }
                }
                catch (HttpException)
                {
                    // The response have been manually flushed and no headers can be added to the response.
                }
            }

            this.Sink.Write(buffer, offset, count);
        }