/// <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); }
public HttpMessageDecoder(IBodyDecoder decoder) { _headerParser = new HeaderParser(); _headerParser.HeaderParsed = OnHeader; _headerParser.RequestLineParsed = OnRequestLine; _headerParser.Completed = OnHeaderParsed; BodyDecoder = decoder; _messageReceived = delegate { }; }
/// <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="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> /// Add another handlers. /// </summary> /// <param name="mimeType">Mime type</param> /// <param name="decoder">The decoder implementation. Must be thread safe.</param> public void Add(string mimeType, IBodyDecoder decoder) { if (mimeType == null) { throw new ArgumentNullException("mimeType"); } if (decoder == null) { throw new ArgumentNullException("decoder"); } _decoders[mimeType] = decoder; }
/// <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> /// Add another handlers. /// </summary> /// <param name="mimeType">Mime type</param> /// <param name="decoder">The decoder implementation. Must be thread safe.</param> public void Add(string mimeType, IBodyDecoder decoder) { if (mimeType == null) throw new ArgumentNullException("mimeType"); if (decoder == null) throw new ArgumentNullException("decoder"); _decoders[mimeType] = decoder; }
/// <summary> /// Add a decoder. /// </summary> /// <param name="decoder">decoder to add</param> /// <remarks> /// Adding zero decoders will make the server add the /// default ones which is <see cref="MultiPartDecoder"/> and <see cref="UrlDecoder"/>. /// </remarks> public void Add(IBodyDecoder decoder) { _bodyDecoders.Add(decoder); }