| | |
| | | package com.sandu.ximon.admin.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.sandu.ximon.admin.utils.request.CommonHeader; |
| | | import org.apache.http.HttpResponse; |
| | | import org.apache.http.NameValuePair; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.client.utils.URIBuilder; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.message.BasicHeader; |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public static String PostWithHeader (String URL, String json, CommonHeader header) { |
| | | System.out.println("****************************************"); |
| | | CloseableHttpClient client = HttpClients.createDefault(); |
| | |
| | | post.setEntity(s); |
| | | HttpResponse httpResponse = client.execute(post); |
| | | InputStream inStream = httpResponse.getEntity().getContent(); |
| | | System.out.println("post: " + JSON.toJSONString(post)); |
| | | |
| | | result = streamToString(inStream,UTF8); |
| | | |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | public static String streamToString(InputStream in, String encoding){ |