我在andorid中创建一些修改http标头的代理服务器,它工作正常,但我必须将完整响应转发到'顶层'.
我如何从HttpURLConnection读取整个响应(所有标题,内容,所有内容)?
HttpURLConnection httpURLConnection;
URL url = new URL(ADDRESS);
httpURLConnection = (HttpURLConnection) url.openConnection();
// add headers, write output stream, flush
if (httpURLConnection.getResponseCode() == HttpsURLConnection.HTTP_OK)
{
Map<String, List<String>> map = httpURLConnection.getHeaderFields();
System.out.println("Printing Response Header...\n");
for (Map.Entry<String, List<String>> entry : map.entrySet())
{
System.out.println("Key : " + entry.getKey() + " ,Value : " + entry.getValue());
}
return new DataInputStream(httpURLConnection.getInputStream());
}
Run Code Online (Sandbox Code Playgroud)
在getInputStream中我只收到内容,可能有一些整个reposne的流?