added chunked encoding support