| | |
| | | if(contentType != null){ |
| | | connection.setRequestProperty("Content-Type", contentType); |
| | | } |
| | | |
| | | connection.connect(); |
| | | |
| | | if(data != null){ |
| | | OutputStream outputStream = connection.getOutputStream(); |
| | | outputStream.write(data.getBytes("utf-8")); |
| | | outputStream.close(); |
| | | } |
| | | |
| | | int responseCode = connection.getResponseCode(); |
| | | if (responseCode == HttpsURLConnection.HTTP_OK) { |
| | | return connection.getInputStream(); |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(connection != null){ |
| | | connection.disconnect(); |
| | | } |
| | | |
| | | } |
| | | return null; |
| | | } |