예제 #1
0
 public IBuildResponse Begin( HttpStatus status, Action<IDefineHeaders> headers ) 
 {
     var responseHeaders = new Dictionary<string,string>();
     var headerDefinition = new HeaderBuilder( responseHeaders );
     headers( headerDefinition );
     ChunkResponse = responseHeaders.Any( x => x.Key == HttpHeader.TRANSFER_ENCODING && x.Value.Equals( "chunked" ));
     Respond( status.ToString(), responseHeaders, Setup );
     return this;
 }
예제 #2
0
        public void Begin( string status, IDictionary<string, string> headers )
        {
            var builder = new DelimitedBuilder("\r\n");
            var headerBuilder = new HeaderBuilder( headers );

            builder.AppendFormat( "HTTP/1.1 {0}", status );

            headers.ForEach( x => builder.AppendFormat( "{0}: {1}", x.Key, x.Value ) );
            builder.Append( "\r\n" );
            var header = builder.ToString();
            var headerBuffer = Encoding.UTF8.GetBytes( header );
			PendingWrite.Reset();
            OnNext( new ArraySegment<byte>(headerBuffer), () => PendingWrite.Set() );
        }