MCPcopy Index your code
hub / github.com/OpenFeign/feign / convertResponse

Method convertResponse

core/src/main/java/feign/DefaultClient.java:94–135  ·  view source on GitHub ↗
(HttpURLConnection connection, Request request)

Source from the content-addressed store, hash-verified

92 }
93
94 Response convertResponse(HttpURLConnection connection, Request request) throws IOException {
95 int status = connection.getResponseCode();
96 String reason = connection.getResponseMessage();
97
98 if (status < 0) {
99 throw new IOException(
100 format(
101 "Invalid status(%s) executing %s %s",
102 status, connection.getRequestMethod(), connection.getURL()));
103 }
104
105 Map<String, Collection<String>> headers = new TreeMap<>(CASE_INSENSITIVE_ORDER);
106 for (Map.Entry<String, List<String>> field : connection.getHeaderFields().entrySet()) {
107 // response message
108 if (field.getKey() != null) {
109 headers.put(field.getKey(), field.getValue());
110 }
111 }
112
113 Integer length = connection.getContentLength();
114 if (length == -1) {
115 length = null;
116 }
117 InputStream stream;
118 if (status >= 400) {
119 stream = connection.getErrorStream();
120 } else {
121 stream = connection.getInputStream();
122 }
123 if (stream != null && this.isGzip(headers.get(CONTENT_ENCODING))) {
124 stream = new GZIPInputStream(stream);
125 } else if (stream != null && this.isDeflate(headers.get(CONTENT_ENCODING))) {
126 stream = new InflaterInputStream(stream);
127 }
128 return Response.builder()
129 .status(status)
130 .reason(reason)
131 .headers(headers)
132 .request(request)
133 .body(stream, length)
134 .build();
135 }
136
137 public HttpURLConnection getConnection(final URL url) throws IOException {
138 return (HttpURLConnection) url.openConnection();

Callers 1

executeMethod · 0.95

Calls 14

isGzipMethod · 0.95
isDeflateMethod · 0.95
builderMethod · 0.95
formatMethod · 0.80
getInputStreamMethod · 0.80
putMethod · 0.65
getValueMethod · 0.65
getMethod · 0.65
bodyMethod · 0.65
headersMethod · 0.65
buildMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected