// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/auth/GalaxyFDSCredential.java
// public interface GalaxyFDSCredential {
// 
//   /**
//    * Add HTTP header to request
//    * @param request
//    */
//   void addHeader(HttpRequestBase request) throws GalaxyFDSClientException;
// 
//   /**
//    * Adds parameter to the URL string
//    * @param uri
//    * @return
//    */
//   String addParam(String uri);
// }
// 
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/exception/GalaxyFDSClientException.java
// public class GalaxyFDSClientException extends Exception {
// 
//   public GalaxyFDSClientException() {}
// 
//   public GalaxyFDSClientException(String message) {
//     super(message);
//   }
// 
//   public GalaxyFDSClientException(Throwable cause) {
//     super(cause);
//   }
// 
//   public GalaxyFDSClientException(String message, Throwable cause) {
//     super(message, cause);
//   }
// }
// 
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/model/HttpHeaders.java
// public final class HttpHeaders {
//   /** RFC 1945 (HTTP/1.0) Section 10.2, RFC 2616 (HTTP/1.1) Section 14.8 */
//   public static final String AUTHORIZATION = "Authorization";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.9 */
//   public static final String CACHE_CONTROL = "Cache-Control";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.3, RFC 2616 (HTTP/1.1) Section 14.11 */
//   public static final String CONTENT_ENCODING = "Content-Encoding";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.4, RFC 2616 (HTTP/1.1) Section 14.13 */
//   public static final String CONTENT_LENGTH = "Content-Length";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.15 */
//   public static final String CONTENT_MD5 = "Content-MD5";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.16 */
//   public static final String CONTENT_RANGE = "Content-Range";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.5, RFC 2616 (HTTP/1.1) Section 14.17 */
//   public static final String CONTENT_TYPE = "Content-Type";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.6, RFC 2616 (HTTP/1.1) Section 14.18 */
//   public static final String DATE = "Date";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.10, RFC 2616 (HTTP/1.1) Section 14.29 */
//   public static final String LAST_MODIFIED = "Last-Modified";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.35 */
//   public static final String RANGE = "Range";
// }


import java.util.Date;
import java.util.Map;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
import com.xiaomi.infra.galaxy.fds.android.auth.GalaxyFDSCredential;
import com.xiaomi.infra.galaxy.fds.android.exception.GalaxyFDSClientException;
import com.xiaomi.infra.galaxy.fds.android.model.HttpHeaders;
import com.xiaomi.infra.galaxy.fds.model.HttpMethod;
package com.xiaomi.infra.galaxy.fds.android.util;




public class RequestFactory {
  public static HttpUriRequest createRequest(String uri,
      GalaxyFDSCredential credential, HttpMethod method,
      Map<String, String> headers) throws GalaxyFDSClientException {
    uri = credential.addParam(uri);
    HttpRequestBase request;
    switch(method) {
      case GET:
        request = new HttpGet(uri);
        break;
      case PUT:
        request = new HttpPut(uri);
        break;
      case POST:
        request = new HttpPost(uri);
        break;
      case DELETE:
        request = new HttpDelete(uri);
        break;
      case HEAD:
        request = new HttpHead(uri);
        break;
      default:
        request = null;
        break;
    }

    if (request != null) {
      if (headers != null) {
        // Should not set content length here, otherwise the fucking apache
        // library will throw an exception
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/auth/GalaxyFDSCredential.java
// public interface GalaxyFDSCredential {
// 
//   /**
//    * Add HTTP header to request
//    * @param request
//    */
//   void addHeader(HttpRequestBase request) throws GalaxyFDSClientException;
// 
//   /**
//    * Adds parameter to the URL string
//    * @param uri
//    * @return
//    */
//   String addParam(String uri);
// }
// 
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/exception/GalaxyFDSClientException.java
// public class GalaxyFDSClientException extends Exception {
// 
//   public GalaxyFDSClientException() {}
// 
//   public GalaxyFDSClientException(String message) {
//     super(message);
//   }
// 
//   public GalaxyFDSClientException(Throwable cause) {
//     super(cause);
//   }
// 
//   public GalaxyFDSClientException(String message, Throwable cause) {
//     super(message, cause);
//   }
// }
// 
// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/model/HttpHeaders.java
// public final class HttpHeaders {
//   /** RFC 1945 (HTTP/1.0) Section 10.2, RFC 2616 (HTTP/1.1) Section 14.8 */
//   public static final String AUTHORIZATION = "Authorization";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.9 */
//   public static final String CACHE_CONTROL = "Cache-Control";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.3, RFC 2616 (HTTP/1.1) Section 14.11 */
//   public static final String CONTENT_ENCODING = "Content-Encoding";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.4, RFC 2616 (HTTP/1.1) Section 14.13 */
//   public static final String CONTENT_LENGTH = "Content-Length";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.15 */
//   public static final String CONTENT_MD5 = "Content-MD5";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.16 */
//   public static final String CONTENT_RANGE = "Content-Range";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.5, RFC 2616 (HTTP/1.1) Section 14.17 */
//   public static final String CONTENT_TYPE = "Content-Type";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.6, RFC 2616 (HTTP/1.1) Section 14.18 */
//   public static final String DATE = "Date";
// 
//   /** RFC 1945 (HTTP/1.0) Section 10.10, RFC 2616 (HTTP/1.1) Section 14.29 */
//   public static final String LAST_MODIFIED = "Last-Modified";
// 
//   /** RFC 2616 (HTTP/1.1) Section 14.35 */
//   public static final String RANGE = "Range";
// }


// Path: src/main/java/com/xiaomi/infra/galaxy/fds/android/util/RequestFactory.java
import java.util.Date;
import java.util.Map;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
import com.xiaomi.infra.galaxy.fds.android.auth.GalaxyFDSCredential;
import com.xiaomi.infra.galaxy.fds.android.exception.GalaxyFDSClientException;
import com.xiaomi.infra.galaxy.fds.android.model.HttpHeaders;
import com.xiaomi.infra.galaxy.fds.model.HttpMethod;

package com.xiaomi.infra.galaxy.fds.android.util;




public class RequestFactory {
  public static HttpUriRequest createRequest(String uri,
      GalaxyFDSCredential credential, HttpMethod method,
      Map<String, String> headers) throws GalaxyFDSClientException {
    uri = credential.addParam(uri);
    HttpRequestBase request;
    switch(method) {
      case GET:
        request = new HttpGet(uri);
        break;
      case PUT:
        request = new HttpPut(uri);
        break;
      case POST:
        request = new HttpPost(uri);
        break;
      case DELETE:
        request = new HttpDelete(uri);
        break;
      case HEAD:
        request = new HttpHead(uri);
        break;
      default:
        request = null;
        break;
    }

    if (request != null) {
      if (headers != null) {
        // Should not set content length here, otherwise the fucking apache
        // library will throw an exception
        headers.remove(HttpHeaders.CONTENT_LENGTH);