Skip to content

Commit 21d5c93

Browse files
committed
feat(HttpRequest): 添加 public HttpRequest mediaType(MediaTypeEnum mediaType) 方法
1 parent 243736b commit 21d5c93

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

admin4j-common-http/src/main/java/io/github/admin4j/http/HttpRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public HttpRequest method(Method method) {
9090
return this;
9191
}
9292

93+
public HttpRequest mediaType(MediaTypeEnum mediaType) {
94+
this.mediaType = mediaType;
95+
return this;
96+
}
97+
9398
public HttpRequest userAgent(String userAgent) {
9499
if (headers == null) {
95100
headers = new HashMap<>(8);

admin4j-common-http/src/test/java/http/TestProxy.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ void getStr() throws IOException {
2424

2525
HttpConfig.ProxyConfig proxyConfig = new HttpConfig.ProxyConfig();
2626
proxyConfig.setHost("119.8.115.201");
27-
proxyConfig.setPort(9892);
28-
proxyConfig.setUserName("ces");
29-
proxyConfig.setPassword("iIl1o0O");
27+
proxyConfig.setPort(9898);
28+
proxyConfig.setUserName("ces_order");
29+
proxyConfig.setPassword("23451Order");
3030
httpConfig.setProxy(proxyConfig);
3131

3232
OkHttpClient okHttpClient = HttpClientFactory.okHttpClient(httpConfig);
3333

3434
ApiJsonClient apiClient = new ApiJsonClient(httpConfig);
3535
// apiClient.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36");
36-
//JSONObject jsonObject = apiClient.get("https://2022.ip138.com/");
36+
// JSONObject jsonObject = apiClient.get("https://2022.ip138.com/");
3737

3838
Map<String, Object> formParams = new HashMap<>(16);
3939
formParams.put("username", "admin");
4040
formParams.put("password", "admin123");
41-
JSONMapper object = apiClient.postForm("https://www.baidu.com/?/auth/login",
41+
JSONMapper object = apiClient.get("https://api.onbuy.com/v2/auth/request-token",
4242
formParams
4343
);
4444
System.out.println("post = " + object);

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<properties>
1919
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2020
<java.version>1.8</java.version>
21-
<revision>0.8.1</revision>
21+
<revision>0.9.0</revision>
2222
</properties>
2323

2424
<build>

0 commit comments

Comments
 (0)