コード例 #1
0
 private void AddHeaderToRequest(HttpRequest request, string headerLine)
 {
     var hp = headerLine.Split(new[] { ':' }, 2);
     var hn = hp[0].Trim();
     var hv = hp.Length == 2 ? hp[1].Trim() : string.Empty;
     request.AddHeader(hn, hv);
 }
コード例 #2
0
        private HttpRequest CreateRequest(string firstRequestLine)
        {
            var firstRequestLineParts = firstRequestLine.Split(' ');
            if (firstRequestLineParts.Length != 3)
            {
                throw new ParserException(
                    "Invalid format for the first request line. Expected format: [Method] [Uri] HTTP/[Version]");
            }

            var requestObject = new HttpRequest(firstRequestLineParts[0], firstRequestLineParts[1], firstRequestLineParts[2]);
            return requestObject;
        }