package com.qiniu.android.http.request;

import java.util.HashMap;
import java.util.Map;

public class Request {

    public static final String HttpMethodHEAD = "HEAD";
    public static final String HttpMethodGet = "GET";
    public static final String HttpMethodPOST = "POST";
    public static final String HttpMethodPUT = "PUT";

    public final String urlString;
    public final String httpMethod;
    public final Map<String, String> allHeaders;
    public final int timeout;
    public final int connectTimeout;
    public final int readTimeout;
    public final int writeTimeout;
    public byte[] httpBody;

    private String host;

    public Request(String urlString,
                   String httpMethod,
                   Map<String, String> allHeaders,
                   byte[] httpBody,
                   int timeout) {
        this(urlString, httpMethod, allHeaders, httpBody, 10,
                (int) ((timeout - 10) * 0.5),
                (int) ((timeout - 10) * 0.5));
    }

    public Request(String urlString,
                   String httpMethod,
                   Map<String, String> allHeaders,
                   byte[] httpBody,
                   int connectTimeout,
                   int readTimeout,
                   int writeTimeout) {

        this.urlString = urlString;
        this.httpMethod = (httpMethod != null) ? httpMethod : HttpMethodGet;
        this.allHeaders = (allHeaders != null) ? allHeaders : new HashMap<String, String>();
        this.httpBody = (httpBody != null) ? httpBody : new byte[0];
        this.connectTimeout = connectTimeout;
        this.readTimeout = readTimeout;
        this.writeTimeout = writeTimeout;
        this.timeout = connectTimeout + writeTimeout + readTimeout;
    }

    void setHost(String host) {
        this.host = host;
    }

    public String getHost() {
        return host;
    }

    protected boolean isValid() {
        return this.urlString == null || httpMethod == null;
    }
}

@@ -905,39 +905,32 @@
                 
-(int) (
 (timeout - 10) *
@@ -928,22 +928,20 @@
 t - 10) 
-* 0.5)
+%3E%3E 1
 ,%0A      
@@ -954,15 +954,8 @@
     
-(int) (
 (tim
@@ -969,14 +969,12 @@
 10) 
-* 0.5)
+%3E%3E 1
 );%0A 

optimize code: Request