예제 #1
0
        /// <inheritdoc />
        IDataStream IEditorView.GetValue()
        {
            HttpData.Builder builder;
            try
            {
                builder = HttpHeaderParser.ParseStartLine(statusLine.Text + "\r\n");
            }
            catch (InvalidHttpHeaderException)
            {
                MessageBox.Show("Invalid status line", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
            foreach (DataGridViewRow row in headers.Rows)
            {
                if (row.Cells[0].Value == null || row.Cells[1].Value == null)
                {
                    continue;
                }
                var key = row.Cells[0].Value.ToString();
                var val = row.Cells[1].Value.ToString();
                if (!string.IsNullOrEmpty(key))
                {
                    builder.AddHeader(key, val);
                }
            }
            IDataStream payload = dataViewSelection.Stream;

            return(builder.CreateAndClear(payload));
        }
예제 #2
0
        public void TestParseStartLine(string line, bool isRequest)
        {
            var builder = HttpHeaderParser.ParseStartLine(line + "\r\n");

            Assert.Equal(isRequest, builder.IsRequest);
        }