public static final ByteBuffer parseCGIContent(final ByteBuffer inputBuffer, final Map<HTTPHeader,String> headerOutput)
	{
		char c;	// current character being HDR_INLINE
		ParseState state = ParseState.HDR_INLINE;
		int lastEOLIndex = 0;
		final int origPosition = inputBuffer.position();
		while(inputBuffer.position() < inputBuffer.limit())
		{
			c=(char)inputBuffer.get();
			switch(state)
			{
			case HDR_INLINE:
				if(c=='\r')
					state=ParseState.HDR_EOLN;
				break;
			case HDR_EOLN:
			{
				if (c=='\n')
				{
					final String headerLine = new String(Arrays.copyOfRange(inputBuffer.array(), lastEOLIndex, inputBuffer.position()-2),utf8);
					lastEOLIndex=inputBuffer.position();
					if(headerLine.length()>0) 
					{
						if(headerOutput != null)
							CWHTTPRequest.parseHeaderLine(headerLine, headerOutput);
						state=ParseState.HDR_INLINE;
					}
					else // a blank line means the end of the header section!!!
					{
						inputBuffer.compact();
						inputBuffer.flip();
						return inputBuffer;
					}
				}
				else // an error!
				{
					inputBuffer.position(origPosition);
					return inputBuffer;
				}
				break;
			}
			default:
				return null; // this can't happen
			}
		}
		return ByteBuffer.wrap(new byte[0]);
	}