Skip to content

Commit c1b9376

Browse files
committed
Merge branch '5.0.x'
Closes gh-1756
2 parents 7eb8fcf + 7e55d60 commit c1b9376

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

spring-ws-core/src/main/java/org/springframework/ws/transport/http/AbstractHttpSenderConnection.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ protected final InputStream getResponseInputStream() throws IOException {
111111
return (isGzipResponse()) ? new GZIPInputStream(inputStream) : inputStream;
112112
}
113113

114-
/** Determine whether the response is a GZIP response. */
115-
private boolean isGzipResponse() throws IOException {
114+
/**
115+
* Determine whether the response is a GZIP response.
116+
*/
117+
protected boolean isGzipResponse() throws IOException {
116118
Iterator<String> iterator = getResponseHeaders(HttpTransportConstants.HEADER_CONTENT_ENCODING);
117119
if (iterator.hasNext()) {
118120
String encodingHeader = iterator.next();

spring-ws-core/src/main/java/org/springframework/ws/transport/http/HttpComponents5Connection.java

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
147147
* Receiving response
148148
*/
149149

150+
@Override
151+
protected boolean isGzipResponse() throws IOException {
152+
HttpEntity entity = getHttpEntity();
153+
if (entity != null) {
154+
return HttpTransportConstants.CONTENT_ENCODING_GZIP.equals(entity.getContentEncoding());
155+
}
156+
return super.isGzipResponse();
157+
}
158+
150159
@Override
151160
protected int getResponseCode() throws IOException {
152161
return getHttpResponse().getCode();
@@ -159,28 +168,19 @@ protected String getResponseMessage() throws IOException {
159168

160169
@Override
161170
protected long getResponseContentLength() throws IOException {
162-
163-
if (this.httpResponse instanceof ClassicHttpResponse response) {
164-
165-
HttpEntity entity = response.getEntity();
166-
if (entity != null) {
167-
return entity.getContentLength();
168-
}
171+
HttpEntity entity = getHttpEntity();
172+
if (entity != null) {
173+
return entity.getContentLength();
169174
}
170175
return 0;
171176
}
172177

173178
@Override
174179
protected InputStream getRawResponseInputStream() throws IOException {
175-
176-
if (this.httpResponse instanceof ClassicHttpResponse response) {
177-
178-
HttpEntity entity = response.getEntity();
179-
if (entity != null) {
180-
return entity.getContent();
181-
}
180+
HttpEntity entity = getHttpEntity();
181+
if (entity != null) {
182+
return entity.getContent();
182183
}
183-
184184
throw new IllegalStateException("Response has no enclosing response entity, cannot create input stream");
185185
}
186186

@@ -196,4 +196,11 @@ public Iterator<String> getResponseHeaders(String name) throws IOException {
196196
return Arrays.stream(getHttpResponse().getHeaders(name)).map(NameValuePair::getValue).iterator();
197197
}
198198

199+
private @Nullable HttpEntity getHttpEntity() {
200+
if (this.httpResponse instanceof ClassicHttpResponse response) {
201+
return response.getEntity();
202+
}
203+
return null;
204+
}
205+
199206
}

0 commit comments

Comments
 (0)