示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpService" /> class.
 /// </summary>
 /// <param name="sliceStack">Used to retreive the buffers which are used during message serialization. Make sure that each buffer is large enough to serialize all headers.</param>
 /// <exception cref="System.ArgumentNullException">sliceStack</exception>
 /// <remarks>You typically want to pass a <c>static</c> stack to this constructor if you want performance.</remarks>
 protected HttpService(IBufferSliceStack sliceStack)
 {
     if (sliceStack == null)
     {
         throw new ArgumentNullException("sliceStack");
     }
     _stack = sliceStack;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BodyDecoder"/> class.
 /// </summary>
 /// <param name="decoderService">The decoder service.</param>
 /// <param name="bufferSize">Buffer size of each buffer in the pool. Read the remarks at <see cref="BodyDecoder"/></param>
 /// <param name="sizeLimit">Maximum size of the body in bytes. Larger content will generate a <see cref="HttpStatusCode.RequestEntityTooLarge"/> response which will
 /// be sent back to the client.</param>
 public BodyDecoder(IBodyDecoder decoderService, int bufferSize, int sizeLimit)
 {
     if (decoderService == null) throw new ArgumentNullException("decoderService");
     _decoderService = decoderService;
     _bufferSize = bufferSize;
     _sizeLimit = sizeLimit;
     _bufferPool = new BufferSliceStack(1000, bufferSize);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpMessageBuilder" /> class.
 /// </summary>
 /// <param name="stack">Slices are used when processing incoming data.</param>
 /// <example>
 /// <code>
 /// var builder = new HttpMessageBuilder(new BufferSliceStack(100, 65535));
 /// </code>
 /// </example>
 public HttpMessageBuilder(IBufferSliceStack stack)
 {
     this.stack = stack;
     this.headerParser.HeaderParsed      += this.OnHeader;
     this.headerParser.Completed         += this.OnHeaderComplete;
     this.headerParser.RequestLineParsed += this.OnRequestLine;
     this.bodySlice = this.stack.Pop();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpMessageBuilder" /> class.
 /// </summary>
 /// <param name="stack">Slices are used when processing incoming data.</param>
 /// <example>
 /// <code>
 /// var builder = new HttpMessageBuilder(new BufferSliceStack(100, 65535));
 /// </code>
 /// </example>
 public HttpMessageBuilder(IBufferSliceStack stack)
 {
     _stack = stack;
     _headerParser.HeaderParsed      += OnHeader;
     _headerParser.Completed         += OnHeaderComplete;
     _headerParser.RequestLineParsed += OnRequestLine;
     _bodySlice = _stack.Pop();
 }
 /// <summary>
 /// Checks if the supplied stack is the one that we came from
 /// </summary>
 /// <param name="stack">Stack to check</param>
 /// <returns><c>>true</c> if our; otherwise <c>false</c>.</returns>
 public bool IsMyStack(IBufferSliceStack stack)
 {
     if (stack == null)
     {
         throw new ArgumentNullException("stack");
     }
     return(ReferenceEquals(_bufferSliceStack, stack));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpMessageBuilder" /> class.
 /// </summary>
 /// <param name="stack">Slices are used when processing incoming data.</param>
 /// <example>
 /// <code>
 /// var builder = new HttpMessageBuilder(new BufferSliceStack(100, 65535)); 
 /// </code>
 /// </example>
 public HttpMessageBuilder(IBufferSliceStack stack)
 {
     _stack = stack;
     _headerParser.HeaderParsed += OnHeader;
     _headerParser.Completed += OnHeaderComplete;
     _headerParser.RequestLineParsed += OnRequestLine;
     _bodySlice = _stack.Pop();
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BodyDecoder"/> class.
 /// </summary>
 /// <param name="decoderService">The decoder service.</param>
 /// <param name="bufferSize">Buffer size of each buffer in the pool. Read the remarks at <see cref="BodyDecoder"/></param>
 /// <param name="sizeLimit">Maximum size of the body in bytes. Larger content will generate a <see cref="HttpStatusCode.RequestEntityTooLarge"/> response which will
 /// be sent back to the client.</param>
 public BodyDecoder(IBodyDecoder decoderService, int bufferSize, int sizeLimit)
 {
     if (decoderService == null)
     {
         throw new ArgumentNullException("decoderService");
     }
     _decoderService = decoderService;
     _bufferSize     = bufferSize;
     _sizeLimit      = sizeLimit;
     _bufferPool     = new BufferSliceStack(1000, bufferSize);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PooledBufferSlice" /> class.
        /// </summary>
        /// <param name="bufferSliceStack">The buffer slice stack.</param>
        /// <param name="buffer">The buffer.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="count">The count.</param>
        public PooledBufferSlice(IBufferSliceStack bufferSliceStack, byte[] buffer, int offset, int count)
        {
            if (bufferSliceStack == null) throw new ArgumentNullException("bufferSliceStack");
            if (buffer == null) throw new ArgumentNullException("buffer");

            Buffer = buffer;
            Offset = offset;
            Count = count;
            _bufferSliceStack = bufferSliceStack;
            _initialSize = count;
            _initialOffset = offset;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BodyDecoder"/> class.
        /// </summary>
        /// <param name="decoderService">The decoder service.</param>
        /// <param name="bufferSliceStack">Used to provide buffers used when decoding the body</param>
        /// <param name="sizeLimit">Maximum size of the body in bytes. Larger content will generate a <see cref="HttpStatusCode.RequestEntityTooLarge"/> response which will
        /// be sent back to the client.</param>
        public BodyDecoder(IBodyDecoder decoderService, IBufferSliceStack bufferSliceStack, int sizeLimit)
        {
            if (decoderService == null) throw new ArgumentNullException("decoderService");
            if (bufferSliceStack == null) throw new ArgumentNullException("bufferSliceStack");
            _decoderService = decoderService;
            _sizeLimit = sizeLimit;
            _bufferPool = bufferSliceStack;

            var buffer = bufferSliceStack.Pop();
            _bufferSize = buffer.Count;
            bufferSliceStack.Push(buffer);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpServer" /> class.
 /// </summary>
 /// <param name="moduleManager">The modules are used to process the HTTP requests. You need to specify at least one.</param>
 /// <param name="configuration">You can override the configuration to your likings. We suggest that you using the <see cref="HttpMessageFactory" /> to produce the messages.</param>
 /// <exception cref="System.ArgumentNullException">moduleManager/configuration</exception>
 public HttpServer(IModuleManager moduleManager, MessagingServerConfiguration configuration)
 {
     if (moduleManager == null) throw new ArgumentNullException("moduleManager");
     if (configuration == null) throw new ArgumentNullException("configuration");
     _moduleManager = moduleManager;
     _server = new MessagingServer(this, configuration);
     _bufferSliceStack = new BufferSliceStack(100, 65535);
     ApplicationInfo = new MemoryItemStorage();
     _workerConfiguration = new WorkerConfiguration
         {
             Application = ApplicationInfo,
             BufferSliceStack = _bufferSliceStack,
             ModuleManager = _moduleManager
         };
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PooledBufferSlice" /> class.
        /// </summary>
        /// <param name="bufferSliceStack">The buffer slice stack.</param>
        /// <param name="buffer">The buffer.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="count">The count.</param>
        public PooledBufferSlice(IBufferSliceStack bufferSliceStack, byte[] buffer, int offset, int count)
        {
            if (bufferSliceStack == null)
            {
                throw new ArgumentNullException("bufferSliceStack");
            }
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            Buffer            = buffer;
            Offset            = offset;
            Count             = count;
            _bufferSliceStack = bufferSliceStack;
            _initialSize      = count;
            _initialOffset    = offset;
        }
示例#12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BodyDecoder"/> class.
        /// </summary>
        /// <param name="decoderService">The decoder service.</param>
        /// <param name="bufferSliceStack">Used to provide buffers used when decoding the body</param>
        /// <param name="sizeLimit">Maximum size of the body in bytes. Larger content will generate a <see cref="HttpStatusCode.RequestEntityTooLarge"/> response which will
        /// be sent back to the client.</param>
        public BodyDecoder(IBodyDecoder decoderService, IBufferSliceStack bufferSliceStack, int sizeLimit)
        {
            if (decoderService == null)
            {
                throw new ArgumentNullException("decoderService");
            }
            if (bufferSliceStack == null)
            {
                throw new ArgumentNullException("bufferSliceStack");
            }
            _decoderService = decoderService;
            _sizeLimit      = sizeLimit;
            _bufferPool     = bufferSliceStack;

            var buffer = bufferSliceStack.Pop();

            _bufferSize = buffer.Count;
            bufferSliceStack.Push(buffer);
        }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpServer" /> class.
 /// </summary>
 /// <param name="moduleManager">The modules are used to process the HTTP requests. You need to specify at least one.</param>
 /// <param name="configuration">You can override the configuration to your likings. We suggest that you using the <see cref="HttpMessageFactory" /> to produce the messages.</param>
 /// <exception cref="System.ArgumentNullException">moduleManager/configuration</exception>
 public HttpServer(IModuleManager moduleManager, MessagingServerConfiguration configuration)
 {
     if (moduleManager == null)
     {
         throw new ArgumentNullException("moduleManager");
     }
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     _moduleManager       = moduleManager;
     _server              = new MessagingServer(this, configuration);
     _bufferSliceStack    = new BufferSliceStack(100, 65535);
     ApplicationInfo      = new MemoryItemStorage();
     _workerConfiguration = new WorkerConfiguration
     {
         Application      = ApplicationInfo,
         BufferSliceStack = _bufferSliceStack,
         ModuleManager    = _moduleManager
     };
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpMessageFactory"/> class.
 /// </summary>
 public HttpMessageFactory()
 {
     this.stack = new BufferSliceStack(100, 65535);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpMessageFactory"/> class.
 /// </summary>
 /// <param name="stack">Used to provide <c>byte[]</c> buffers to the workers..</param>
 public HttpMessageFactory(IBufferSliceStack stack)
 {
     this.stack = stack;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpMessageFactory"/> class.
 /// </summary>
 public HttpMessageFactory()
 {
     _stack = new BufferSliceStack(100, 65535);
 }
 /// <summary>
 /// Checks if the supplied stack is the one that we came from
 /// </summary>
 /// <param name="stack">Stack to check</param>
 /// <returns><c>>true</c> if our; otherwise <c>false</c>.</returns>
 public bool IsMyStack(IBufferSliceStack stack)
 {
     if (stack == null) throw new ArgumentNullException("stack");
     return ReferenceEquals(_bufferSliceStack, stack);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpMessageFactory"/> class.
 /// </summary>
 /// <param name="stack">Used to provide <c>byte[]</c> buffers to the workers..</param>
 public HttpMessageFactory(IBufferSliceStack stack)
 {
     _stack = stack;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpService" /> class.
 /// </summary>
 /// <param name="sliceStack">Used to retreive the buffers which are used during message serialization. Make sure that each buffer is large enough to serialize all headers.</param>
 /// <exception cref="System.ArgumentNullException">sliceStack</exception>
 /// <remarks>You typically want to pass a <c>static</c> stack to this constructor if you want performance.</remarks>
 protected HttpService(IBufferSliceStack sliceStack)
 {
     if (sliceStack == null) throw new ArgumentNullException("sliceStack");
     _stack = sliceStack;
 }