// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
// 
//     private String url;
// 
//     private Map<String, String> headers;
// 
//     private String body;
// 
// 
//     public void setUrl(String url) {
//         this.url = url;
//     }
// 
//     public void setHeaders(Map<String, String> headers) {
//         this.headers = headers;
//     }
// 
//     public void setBody(String body) {
//         this.body = body;
//     }
// 
//     public String getUrl() {
//         return url;
//     }
// 
//     public Map<String, String> getHeaders() {
//         return headers;
//     }
// 
//     public String getBody() {
//         return body;
//     }
// }
// 
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
// 
//     Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
// 
// }
// 
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
// 
//     void onProgressChanged(Progress progress);
// 
// }
// 
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
// 
//     public String get(String url) throws Exception {
//         return doRequest(url, "GET", null, null);
//     }
// 
//     public String get(String url, Map<String, String> headers) throws Exception {
//         return doRequest(url, "GET", headers, null);
//     }
// 
//     public String post(String url, Map<String, String> header, String body) throws Exception {
//         return doRequest(url, "POST", header, body);
//     }
// 
//     private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
//         String response = null;
//         HttpURLConnection connection = null;
//         try {
//             URL reqUrl = new URL(url);
//             connection = ((HttpURLConnection) reqUrl.openConnection());
//             connection.setRequestMethod(type);
//             if (header != null) {
//                 for (String key : header.keySet()) {
//                     connection.addRequestProperty(key, header.get(key));
//                 }
//             }
//             if (body != null) {
//                 applyBody(connection, body);
//             }
// 
//             InputStream inputStream;
// 
//             boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
//             if (isSuccess) {
//                 inputStream = connection.getInputStream();
//             } else {
//                 inputStream = connection.getErrorStream();
//             }
// 
//             BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
//             StringBuilder stringBuilder = new StringBuilder();
//             String line;
//             while ((line = reader.readLine()) != null) {
//                 stringBuilder.append(line);
//             }
//             response = stringBuilder.toString();
// 
//             inputStream.close();
// 
//             if (!isSuccess) {
//                 System.out.println("http exception = " + response);
//                 throw new Exception(response);
//             }
// 
//         } finally {
//             if (connection != null) {
//                 connection.disconnect();
//             }
//         }
//         return response;
//     }
// 
//     public interface ResultConverter<Result> {
// 
//         Result convert(InputStream inputStream);
// 
//     }
// 
//     public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
//         HttpURLConnection connection = null;
//         InputStream inputStream = null;
//         try {
//             URL reqUrl = new URL(url);
//             connection = ((HttpURLConnection) reqUrl.openConnection());
//             connection.setRequestMethod("GET");
//             inputStream = connection.getInputStream();
//             return resultConverter.convert(inputStream);
//         } finally {
//             if (inputStream != null) {
//                 inputStream.close();
//             }
//             if (connection != null) {
//                 connection.disconnect();
//             }
//         }
//     }
// 
//     private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
//         byte[] outputInBytes = body.getBytes("UTF-8");
//         OutputStream os = httpURLConnection.getOutputStream();
//         os.write(outputInBytes);
//         os.close();
//     }
// 
// 
// }


import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient;
package com.example.mikhail_sianko.myapplication.threads.operation;


public class HttpPostOperation implements Operation<HttpRequestModel, Void, String> {

    @Override
    public String doing(HttpRequestModel inputRequestModel, ProgressCallback<Void> progressCallback) throws Exception {
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
// 
//     private String url;
// 
//     private Map<String, String> headers;
// 
//     private String body;
// 
// 
//     public void setUrl(String url) {
//         this.url = url;
//     }
// 
//     public void setHeaders(Map<String, String> headers) {
//         this.headers = headers;
//     }
// 
//     public void setBody(String body) {
//         this.body = body;
//     }
// 
//     public String getUrl() {
//         return url;
//     }
// 
//     public Map<String, String> getHeaders() {
//         return headers;
//     }
// 
//     public String getBody() {
//         return body;
//     }
// }
// 
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
// 
//     Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
// 
// }
// 
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
// 
//     void onProgressChanged(Progress progress);
// 
// }
// 
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
// 
//     public String get(String url) throws Exception {
//         return doRequest(url, "GET", null, null);
//     }
// 
//     public String get(String url, Map<String, String> headers) throws Exception {
//         return doRequest(url, "GET", headers, null);
//     }
// 
//     public String post(String url, Map<String, String> header, String body) throws Exception {
//         return doRequest(url, "POST", header, body);
//     }
// 
//     private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
//         String response = null;
//         HttpURLConnection connection = null;
//         try {
//             URL reqUrl = new URL(url);
//             connection = ((HttpURLConnection) reqUrl.openConnection());
//             connection.setRequestMethod(type);
//             if (header != null) {
//                 for (String key : header.keySet()) {
//                     connection.addRequestProperty(key, header.get(key));
//                 }
//             }
//             if (body != null) {
//                 applyBody(connection, body);
//             }
// 
//             InputStream inputStream;
// 
//             boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
//             if (isSuccess) {
//                 inputStream = connection.getInputStream();
//             } else {
//                 inputStream = connection.getErrorStream();
//             }
// 
//             BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
//             StringBuilder stringBuilder = new StringBuilder();
//             String line;
//             while ((line = reader.readLine()) != null) {
//                 stringBuilder.append(line);
//             }
//             response = stringBuilder.toString();
// 
//             inputStream.close();
// 
//             if (!isSuccess) {
//                 System.out.println("http exception = " + response);
//                 throw new Exception(response);
//             }
// 
//         } finally {
//             if (connection != null) {
//                 connection.disconnect();
//             }
//         }
//         return response;
//     }
// 
//     public interface ResultConverter<Result> {
// 
//         Result convert(InputStream inputStream);
// 
//     }
// 
//     public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
//         HttpURLConnection connection = null;
//         InputStream inputStream = null;
//         try {
//             URL reqUrl = new URL(url);
//             connection = ((HttpURLConnection) reqUrl.openConnection());
//             connection.setRequestMethod("GET");
//             inputStream = connection.getInputStream();
//             return resultConverter.convert(inputStream);
//         } finally {
//             if (inputStream != null) {
//                 inputStream.close();
//             }
//             if (connection != null) {
//                 connection.disconnect();
//             }
//         }
//     }
// 
//     private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
//         byte[] outputInBytes = body.getBytes("UTF-8");
//         OutputStream os = httpURLConnection.getOutputStream();
//         os.write(outputInBytes);
//         os.close();
//     }
// 
// 
// }


// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpPostOperation.java
import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient;

package com.example.mikhail_sianko.myapplication.threads.operation;


public class HttpPostOperation implements Operation<HttpRequestModel, Void, String> {

    @Override
    public String doing(HttpRequestModel inputRequestModel, ProgressCallback<Void> progressCallback) throws Exception {
        HttpClient httpClient = new HttpClient();