|
1 | 1 | package com.codingapi.springboot.framework.rest;
|
2 | 2 |
|
| 3 | +import com.alibaba.fastjson.JSONObject; |
3 | 4 | import com.codingapi.springboot.framework.rest.param.RestParamBuilder;
|
4 | 5 | import com.codingapi.springboot.framework.rest.properties.HttpProxyProperties;
|
5 | 6 | import org.springframework.http.HttpHeaders;
|
6 | 7 | import org.springframework.http.HttpStatus;
|
| 8 | +import org.springframework.http.MediaType; |
7 | 9 | import org.springframework.http.ResponseEntity;
|
8 | 10 |
|
9 | 11 | import java.net.URI;
|
@@ -63,16 +65,36 @@ public SessionClient addHeader(String key, String value){
|
63 | 65 | return this;
|
64 | 66 | }
|
65 | 67 |
|
66 |
| - public String post(String url, RestParamBuilder restParam){ |
| 68 | + public String postForm(String url, RestParamBuilder restParam){ |
| 69 | + httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
67 | 70 | return httpClient.post(url,httpHeaders,restParam.toFormRequest());
|
68 | 71 | }
|
69 | 72 |
|
70 |
| - public String get(String url){ |
71 |
| - return get(url,null); |
| 73 | + public String postJson(String url, RestParamBuilder restParam){ |
| 74 | + httpHeaders.setContentType(MediaType.APPLICATION_JSON); |
| 75 | + return httpClient.post(url,httpHeaders,restParam.toJsonRequest()); |
72 | 76 | }
|
73 | 77 |
|
74 |
| - public String get(String url,RestParamBuilder restParam){ |
| 78 | + public String postJson(String url, JSONObject requestBody){ |
| 79 | + httpHeaders.setContentType(MediaType.APPLICATION_JSON); |
| 80 | + return httpClient.post(url,httpHeaders,requestBody); |
| 81 | + } |
| 82 | + |
| 83 | + public String getJson(String url){ |
| 84 | + return getJson(url,null); |
| 85 | + } |
| 86 | + |
| 87 | + public String getHtml(String url){ |
| 88 | + return getHtml(url,null); |
| 89 | + } |
| 90 | + |
| 91 | + public String getHtml(String url,RestParamBuilder restParam){ |
| 92 | + httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
75 | 93 | return httpClient.get(url,httpHeaders,restParam!=null?restParam.toFormRequest():null);
|
76 | 94 | }
|
77 | 95 |
|
| 96 | + public String getJson(String url,RestParamBuilder restParam){ |
| 97 | + httpHeaders.setContentType(MediaType.APPLICATION_JSON); |
| 98 | + return httpClient.get(url,httpHeaders,restParam!=null?restParam.toFormRequest():null); |
| 99 | + } |
78 | 100 | }
|
0 commit comments