@Override
	public void onDownstreamMessageEvent(ChannelMessageEvent event,
														PipelineHandlerContext context)
			throws Exception
	{
		if( !(event.getMessage() instanceof HttpResponse) )
		{
			context.sendDownstream(event);
			return;
		}

		HttpResponse response = (HttpResponse) event.getMessage();

		if( response.getBodyBuffer() != null )
		{
			response.setHeader("content-length", Integer.toString(response
					.getBodyBuffer().getReadableBytes()));
		}

		StringBuilder headBuffer = new StringBuilder();

		headBuffer.append("HTTP/1.0 ").append(response.getCode()).append(" ")
				.append(codeList.get(response.getCode())).append("\r\n");

		Iterator<Entry<String, LinkedList<String>>> it = response.getHeader()
				.entrySet().iterator();
		while( it.hasNext() )
		{
			Entry<String, LinkedList<String>> entry = it.next();

			/*
			 * StringBuffer buffer = new StringBuffer(entry.getKey());
			 * 
			 * char lastChar = 0; int len = buffer.length(); for(int i = 0; i <
			 * len; i++) { char c = buffer.charAt(i); if( lastChar < 'a' ||
			 * lastChar > 'z' ) buffer.setCharAt(i, Character.toUpperCase(c));
			 * 
			 * lastChar = c; }
			 */

			Iterator<String> it2 = entry.getValue().iterator();

			while( it2.hasNext() )
			{
				String value = it2.next();
				if( value != null )
					headBuffer.append(entry.getKey()).append(": ").append(value)
							.append("\r\n");
			}
		}

		headBuffer.append("\r\n");

		IOBuffer headIoBuffer = DynamicIOBuffer.create();
		headIoBuffer.writeString(headBuffer, HEADER_CHARSET);

		if( response.getBodyBuffer() != null
				&& !"head".equals(response.getRequest().getMethod()) )
		{
			context.sendDownstream(headIoBuffer)
					.addListener(new ChannelEventFutureListener()
					{

						@Override
						public void onAction(ChannelEventFuture future)
						{
							System.out.println(future.getException());
						}
					});;
			context.sendDownstream(response.getBodyBuffer())
					.addListener(new ChannelEventFutureListener()
					{

						@Override
						public void onAction(ChannelEventFuture future)
						{
							System.out.println(future.getException());
						}
					});
		}
		else
			context.sendDownstream(headIoBuffer)
					.addListener(ChannelEventFutureListener.CLOSE);

		headIoBuffer.free();
		if( response.getBodyBuffer() != null )
			response.getBodyBuffer().free();
	}