package br.com.caelum.rest.client.http;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import java.util.Map;

public class Response {

	private int code;
	private String content;
	private Map<String, List<String>> headers;

	public Response(HttpURLConnection connection) throws IOException {
		this.code = connection.getResponseCode();
		this.content = connection.getContent().toString();
		this.headers = connection.getHeaderFields();
	}

	public int getCode() {
		return code;
	}

	public String getContent() {
		return content;
	}

	public List<String> getHeader(String key) {
		return headers.get(key);
	}
	
	

}

@@ -49,27 +49,120 @@
 java.io.
-IOException
+BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader
 ;%0Aimport
@@ -303,16 +303,21 @@
  content
+ = %22%22
 ;%0A%09priva
@@ -473,58 +473,320 @@
 ;%0A%09%09
-this.content = connection.getContent().toString();
+InputStream stream =  (InputStream) connection.getContent();%0A%09%09BufferedReader reader = new BufferedReader(new InputStreamReader(stream));%0A%09%09while(true) %7B%0A%09%09%09String partial = reader.readLine();%0A%09%09%09if(partial==null)%7B%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%09if(content.length()!=0) %7B%0A%09%09%09%09content += %22%5Cn%22;%0A%09%09%09%7D%0A%09%09%09content += partial;%0A%09%09%7D
 %0A%09%09t

read corectly the response