Skip to content

Commit

Permalink
feat(HttpRequest): 添加 public HttpRequest mediaType(MediaTypeEnum medi…
Browse files Browse the repository at this point in the history
…aType) 方法
  • Loading branch information
andanyoung committed Nov 27, 2023
1 parent 243736b commit 21d5c93
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public HttpRequest method(Method method) {
return this;
}

public HttpRequest mediaType(MediaTypeEnum mediaType) {
this.mediaType = mediaType;
return this;
}

public HttpRequest userAgent(String userAgent) {
if (headers == null) {
headers = new HashMap<>(8);
Expand Down
10 changes: 5 additions & 5 deletions admin4j-common-http/src/test/java/http/TestProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ void getStr() throws IOException {

HttpConfig.ProxyConfig proxyConfig = new HttpConfig.ProxyConfig();
proxyConfig.setHost("119.8.115.201");
proxyConfig.setPort(9892);
proxyConfig.setUserName("ces");
proxyConfig.setPassword("iIl1o0O");
proxyConfig.setPort(9898);
proxyConfig.setUserName("ces_order");
proxyConfig.setPassword("23451Order");
httpConfig.setProxy(proxyConfig);

OkHttpClient okHttpClient = HttpClientFactory.okHttpClient(httpConfig);

ApiJsonClient apiClient = new ApiJsonClient(httpConfig);
// 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");
//JSONObject jsonObject = apiClient.get("https://2022.ip138.com/");
// JSONObject jsonObject = apiClient.get("https://2022.ip138.com/");

Map<String, Object> formParams = new HashMap<>(16);
formParams.put("username", "admin");
formParams.put("password", "admin123");
JSONMapper object = apiClient.postForm("https://www.baidu.com/?/auth/login",
JSONMapper object = apiClient.get("https://api.onbuy.com/v2/auth/request-token",
formParams
);
System.out.println("post = " + object);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<revision>0.8.1</revision>
<revision>0.9.0</revision>
</properties>

<build>
Expand Down

0 comments on commit 21d5c93

Please sign in to comment.