@@ -0,0 +1,2536 @@
+package dmm4j.http;%0A%0A%0Aimport java.io.DataOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.Serializable;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport dmm4j.DmmException;%0Aimport dmm4j.Version;%0Aimport dmm4j.log.Logger;%0A%0Apublic abstract class HttpClientBase implements HttpClient, Serializable %7B%0A  private static final Logger logger = Logger.getLogger(HttpClientBase.class);%0A  private static final long serialVersionUID = -8016974810651763053L;%0A  protected final HttpClientConfiguration CONF;%0A%0A  private final Map%3CString, String%3E requestHeaders;%0A%0A  public HttpClientBase(HttpClientConfiguration conf) %7B%0A    this.CONF = conf;%0A    requestHeaders = new HashMap%3CString, String%3E();%0A    requestHeaders.put(%22X-Dmm-Client-Version%22, Version.getVersion());%0A    requestHeaders.put(%22X-Dmm-Client-URL%22, %22http://Dmm4j.org/en/Dmm4j-%22 + Version.getVersion()%0A        + %22.xml%22);%0A    requestHeaders.put(%22X-Dmm-Client%22, %22Dmm4J%22);%0A    requestHeaders.put(%22User-Agent%22, %22Dmm4j http://Dmm4j.org/ /%22 + Version.getVersion());%0A    if (conf.isGZIPEnabled()) %7B%0A      requestHeaders.put(%22Accept-Encoding%22, %22gzip%22);%0A    %7D%0A  %7D%0A%0A  protected boolean isProxyConfigured() %7B%0A    return CONF.getHttpProxyHost() != null && !CONF.getHttpProxyHost().equals(%22%22);%0A  %7D%0A%0A  public void write(DataOutputStream out, String outStr) throws IOException %7B%0A    out.writeBytes(outStr);%0A    logger.debug(outStr);%0A  %7D%0A%0A  public Map%3CString, String%3E getRequestHeaders() %7B%0A    return requestHeaders;%0A  %7D%0A%0A  public void addDefaultRequestHeader(String name, String value) %7B%0A    requestHeaders.put(name, value);%0A  %7D%0A%0A  public final HttpResponse request(HttpRequest req) throws DmmException %7B%0A    return handleRequest(req);%0A  %7D%0A%0A  abstract HttpResponse handleRequest(HttpRequest req) throws DmmException;%0A%0A  public HttpResponse get(String url) throws DmmException %7B%0A    return request(new HttpRequest(RequestMethod.GET, url, null, this.requestHeaders));%0A  %7D%0A%0A  public HttpResponse post(String url) throws DmmException %7B%0A    return request(new HttpRequest(RequestMethod.POST, url, null, this.requestHeaders));%0A  %7D%0A%0A  public HttpResponse delete(String url) throws DmmException %7B%0A    return request(new HttpRequest(RequestMethod.DELETE, url, null, this.requestHeaders));%0A  %7D%0A%0A  public HttpResponse head(String url) throws DmmException %7B%0A    return request(new HttpRequest(RequestMethod.HEAD, url, null, this.requestHeaders));%0A  %7D%0A%0A  public HttpResponse put(String url) throws DmmException %7B%0A    return request(new HttpRequest(RequestMethod.PUT, url, null, this.requestHeaders));%0A  %7D%0A%0A%0A%7D%0A

Add HttpClientBase