public static HttpHeaderCollection Parse(byte[] buffer, int start) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } if (start < 0 || start >= buffer.Length) { throw new ArgumentOutOfRangeException(nameof(start)); } var headers = new HttpHeaderCollection(); while (true) { try { var header = HttpHeader.Parse(buffer, start); if (header == null) { break; } headers.Add(header); start += header.ByteCount; } catch (Exception ex) { throw new BadHttpDataException("Could not parse header", ex); } } return(headers); }
public static HttpRequestMetadata Parse(byte[] buffer, int start) { // parse line var line = HttpRequestLine.Parse(buffer, start); start += line.ByteCount; // parse headers var headers = HttpHeaderCollection.Parse(buffer, start); var metadata = new HttpRequestMetadata(line, headers); return(metadata); }
public HttpRequestMetadata(HttpRequestLine line, HttpHeaderCollection headers) { this.Line = line ?? throw new ArgumentNullException(nameof(line)); this.Headers = headers ?? throw new ArgumentNullException(nameof(headers)); }