Skip to content

Commit 2883e4f

Browse files
authored
Merge pull request #295 from JiazhenBao/main
LCAPHttpClient.exchangeV3 数据格式为非form,异常时返回http错误信息;threadPause_dellge更新groupid为内部可用
2 parents b59f557 + 78d167e commit 2883e4f

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

httpclient/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ TransferCommonException中errorMsg包含了http状态码和返回信息。格式
2424

2525
出参:第三方返回完整信息的String格式 || TransferCommonException异常
2626

27+
## LCAPHttpClient.exchangeV3 数据格式为非form,异常时返回http错误信息
28+
入参:
29+
- url: 请求地址
30+
- httpMethod: 请求方法
31+
- header: 请求头
32+
- body: 请求体(json String)
33+
34+
出参:第三方返回完整信息的String格式 || TransferCommonException异常
35+
2736
## LCAPHttpClient.exchangeWithoutUriEncode 数据格式为非form,url不编码
2837
入参:
2938
- url: 请求地址

httpclient/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<artifactId>httpclient</artifactId>
1717
<name>httpclient</name>
1818
<description>httpclient</description>
19-
<version>0.17.3</version>
19+
<version>0.18.0</version>
2020

2121
<dependencies>
2222
<dependency>
@@ -72,6 +72,7 @@
7272
<groupId>com.netease.cloud</groupId>
7373
<artifactId>codewave-file-connector-library</artifactId>
7474
<version>1.0.3</version>
75+
<scope>provided</scope>
7576
</dependency>
7677
</dependencies>
7778

httpclient/src/main/java/com/netease/http/httpclient/LCAPHttpClient.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,37 @@ public String exchangeV2(@Required String url, @Required String httpMethod, @Req
118118
}
119119
}
120120

121+
/**
122+
* http/https调用(非form使用,异常时返回http错误码)
123+
*
124+
* @param url
125+
* @param httpMethod
126+
* @param header
127+
* @param body
128+
* @return
129+
* @throws URISyntaxException
130+
*/
131+
@NaslLogic
132+
@Retryable(value = {Exception.class}, maxAttempts = 3, backoff = @Backoff(delay = 1000L))
133+
public String exchangeV3(@Required String url, @Required String httpMethod, @Required Map<String, String> header, @Required String body) throws TransferCommonException {
134+
try {
135+
RequestParamAllBodyTypeInner requestParam = new RequestParamAllBodyTypeInner();
136+
requestParam.setBody(body);
137+
//填充requestParam参数
138+
requestParam.setUrl(url);
139+
requestParam.setHttpMethod(httpMethod);
140+
requestParam.setHeader(header);
141+
ResponseEntity<String> exchange = httpClientService.exchangeInner(requestParam, restTemplate, String.class);
142+
return exchange.getBody();
143+
} catch (HttpClientErrorException e) {
144+
logger.error("", e);
145+
return e.getResponseBodyAsString();
146+
} catch (Exception e) {
147+
logger.error("", e);
148+
throw new TransferCommonException(e.getMessage(), e);
149+
}
150+
}
151+
121152

122153
/**
123154
* 下载文件并上传到nos(默认fileUrl是get请求,默认格式xlsx)

threadPause_dellge/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<relativePath/> <!-- lookup parent from repository -->
1111
</parent>
1212

13-
<groupId>com.thread</groupId>
13+
<groupId>com.netease</groupId>
1414
<artifactId>threadPause</artifactId>
1515
<version>1.0.11</version>
1616
<name>线程等待依赖库</name>

0 commit comments

Comments
 (0)