MCPcopy Create free account
hub / github.com/OreosLab/bili / processResult

Method processResult

src/main/java/top/misec/utils/HttpUtils.java:141–160  ·  view source on GitHub ↗
(CloseableHttpResponse httpResponse)

Source from the content-addressed store, hash-verified

139 }
140
141 public static JsonObject processResult(CloseableHttpResponse httpResponse) {
142 JsonObject resultJson = null;
143
144 if (httpResponse != null) {
145 int responseStatusCode = httpResponse.getStatusLine().getStatusCode();
146 // 从响应对象中获取响应内容
147 // 通过返回对象获取返回数据
148 HttpEntity entity = httpResponse.getEntity();
149
150 String result = null;
151 try {
152 // 通过EntityUtils中的toString方法将结果转换为字符串
153 result = EntityUtils.toString(entity);
154 resultJson = new Gson().fromJson(result, JsonObject.class);
155 } catch (Exception e) {
156 log.debug("HttpUtils parse json error: {}", result.substring(0, 100));
157 }
158 }
159 return resultJson;
160 }
161
162 private static NameValuePair getNameValuePair(Map.Entry<String, JsonElement> entry) {
163 return new BasicNameValuePair(entry.getKey(), Optional.ofNullable(entry.getValue()).map(Object::toString).orElse(null));

Callers 2

doPostMethod · 0.95
doGetMethod · 0.95

Calls 2

toStringMethod · 0.80
fromJsonMethod · 0.80

Tested by

no test coverage detected