@@ -32,22 +32,12 @@ final class Apache5HttpResponse extends LowLevelHttpResponse {
32
32
private final ClassicHttpResponse response ;
33
33
private final Header [] allHeaders ;
34
34
private final HttpEntity entity ;
35
- private final Apache5ResponseContent content ;
36
35
37
36
Apache5HttpResponse (HttpUriRequestBase request , ClassicHttpResponse response ) {
38
37
this .request = request ;
39
38
this .response = response ;
40
39
this .allHeaders = response .getHeaders ();
41
40
this .entity = response .getEntity ();
42
- Apache5ResponseContent contentValue = null ;
43
- if (entity != null ) {
44
- try {
45
- contentValue = new Apache5ResponseContent (entity .getContent (), response );
46
- } catch (IOException ex ) {
47
- LOGGER .log (Level .SEVERE , "Error when obtaining content from the response" , ex );
48
- }
49
- }
50
- this .content = contentValue ;
51
41
}
52
42
53
43
@ Override
@@ -57,7 +47,7 @@ public int getStatusCode() {
57
47
58
48
@ Override
59
49
public InputStream getContent () throws IOException {
60
- return content ;
50
+ return new Apache5ResponseContent ( entity . getContent (), response ) ;
61
51
}
62
52
63
53
@ Override
@@ -109,12 +99,11 @@ public String getHeaderValue(int index) {
109
99
public void disconnect () {
110
100
request .abort ();
111
101
try {
112
- // this call also close the response
113
- content .close ();
102
+ response .close ();
114
103
} catch (IOException e ) {
115
104
// the close() method contract won't allow us to declare a thrown exception. Here we just log
116
105
// the error
117
- LOGGER .log (Level .SEVERE , "Error occurred when closing the content " , e );
106
+ LOGGER .log (Level .SEVERE , "Error occurred when closing the response " , e );
118
107
}
119
108
}
120
109
}
0 commit comments