/// <summary>
    /// Initializes a new instance of the <see cref="MessageFactoryContext"/> class.
    /// </summary>
    /// <param name="messageFactory">消息工厂</param>
    /// <param name="headerFactory">头域工厂</param>
    /// <param name="httpParser">指定的HTTP消息解析器</param>
    public MessageFactoryContext(MessageFactory messageFactory, HeaderFactory headerFactory, MessageParser httpParser)
    {
      _messageFactory = messageFactory;
      _headerFactory = headerFactory;
      _httpParser = httpParser;

      _httpParser.HeaderParsed += OnHeader;
      _httpParser.MessageComplete += OnMessageComplete;
      _httpParser.RequestLineParsed += OnRequestLine;
      _httpParser.ResponseLineParsed += OnResponseLine;
      _httpParser.BodyBytesReceived += OnBody;
    }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageFactory"/> class.
 /// </summary>
 /// <param name="factory">Factory used to create headers.</param>
 public MessageFactory(HeaderFactory factory)
 {
   _factory = factory;
   _builders = new FlyweightObjectPool<MessageFactoryContext>(CreateBuilder);
 }