// Path: CoolHttp/app/src/main/java/com/yanzhenjie/coolhttp/http/utils/CountOutputStream.java
// public class CountOutputStream extends OutputStream {
// 
//     private AtomicLong atomicLong = new AtomicLong();
// 
//     @Override
//     public void write(int b) throws IOException {
//         atomicLong.addAndGet(1);
//     }
// 
//     @Override
//     public void write(byte[] b) throws IOException {
//         atomicLong.addAndGet(b.length);
//     }
// 
//     @Override
//     public void write(byte[] b, int off, int len) throws IOException {
//         atomicLong.addAndGet(len);
//     }
// 
//     public void write(long length) {
//         atomicLong.addAndGet(length);
//     }
// 
//     public long get() {
//         return atomicLong.get();
//     }
// }


import android.text.TextUtils;
import com.yanzhenjie.coolhttp.http.utils.CountOutputStream;
import org.json.JSONObject;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Proxy;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
        // --boundary(start boundary)
        // Content-Disposition: form-data; name="key" // key相当于url?key=value中的key
        // Content-Type: text/plain
        // 换行...
        // Write String
        // --boundary--(end boundary)

        if (!TextUtils.isEmpty(contentType)) return contentType;
        else if (needFormData())
            return "multipart/form-data; boundary=" + boundary;
        else
            return "application/x-www-form-urlencoded";
    }

    private boolean needFormData() {
        if (formData) return true;
        for (KeyValue requestParam : requestParams) {
            Object value = requestParam.getValue();
            if (value instanceof Binary) return true;
        }
        return false;
    }

    /**
     * 统计Content-Length。
     *
     * @return
     * @throws Exception
     */
    long getContentLength() throws Exception {
// Path: CoolHttp/app/src/main/java/com/yanzhenjie/coolhttp/http/utils/CountOutputStream.java
// public class CountOutputStream extends OutputStream {
// 
//     private AtomicLong atomicLong = new AtomicLong();
// 
//     @Override
//     public void write(int b) throws IOException {
//         atomicLong.addAndGet(1);
//     }
// 
//     @Override
//     public void write(byte[] b) throws IOException {
//         atomicLong.addAndGet(b.length);
//     }
// 
//     @Override
//     public void write(byte[] b, int off, int len) throws IOException {
//         atomicLong.addAndGet(len);
//     }
// 
//     public void write(long length) {
//         atomicLong.addAndGet(length);
//     }
// 
//     public long get() {
//         return atomicLong.get();
//     }
// }


// Path: CoolHttp/app/src/main/java/com/yanzhenjie/coolhttp/http/Request.java
import android.text.TextUtils;
import com.yanzhenjie.coolhttp.http.utils.CountOutputStream;
import org.json.JSONObject;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.Proxy;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;

        // --boundary(start boundary)
        // Content-Disposition: form-data; name="key" // key相当于url?key=value中的key
        // Content-Type: text/plain
        // 换行...
        // Write String
        // --boundary--(end boundary)

        if (!TextUtils.isEmpty(contentType)) return contentType;
        else if (needFormData())
            return "multipart/form-data; boundary=" + boundary;
        else
            return "application/x-www-form-urlencoded";
    }

    private boolean needFormData() {
        if (formData) return true;
        for (KeyValue requestParam : requestParams) {
            Object value = requestParam.getValue();
            if (value instanceof Binary) return true;
        }
        return false;
    }

    /**
     * 统计Content-Length。
     *
     * @return
     * @throws Exception
     */
    long getContentLength() throws Exception {
        CountOutputStream outputStream = new CountOutputStream();