@@ -0,0 +1,2239 @@
+/*%0A * Copyright 2015 Hiroki Uchida%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not use this file except%0A * in compliance with the License. You may obtain a copy of the License at%0A * %0A * http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software distributed under the License%0A * is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express%0A * or implied. See the License for the specific language governing permissions and limitations under%0A * the License.%0A */%0A%0Apackage dmm4j.http;%0A%0Aimport java.io.IOException;%0Aimport java.net.HttpURLConnection;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A/**%0A * @author nikuyoshi%0A */%0Apublic class HttpResponseImpl extends HttpResponse %7B%0A  private HttpURLConnection con;%0A%0A  HttpResponseImpl(HttpURLConnection con, HttpClientConfiguration conf) throws IOException %7B%0A    super(conf);%0A    this.con = con;%0A    try %7B%0A      this.statusCode = con.getResponseCode();%0A    %7D catch (IOException e) %7B%0A      /*%0A       * If the user has revoked the access token in use, then Dmm naughtily returns a 401 with no%0A       * %22WWW-Authenticate%22 header.%0A       * %0A       * This causes an IOException in the getResponseCode() method call. See%0A       * https://dev.dmm.com/issues/1114 This call can, however, me made a second time without%0A       * exception.%0A       */%0A      if (%22Received authentication challenge is null%22.equals(e.getMessage())) %7B%0A        this.statusCode = con.getResponseCode();%0A      %7D else %7B%0A        throw e;%0A      %7D%0A    %7D%0A    if (null == (is = con.getErrorStream())) %7B%0A      is = con.getInputStream();%0A    %7D%0A    if (is != null && %22gzip%22.equals(con.getContentEncoding())) %7B%0A      // the response is gzipped%0A      is = new StreamingGZIPInputStream(is);%0A    %7D%0A  %7D%0A%0A  // for test purpose%0A  /* package */HttpResponseImpl(String content) %7B%0A    super();%0A    this.responseAsString = content;%0A  %7D%0A%0A  @Override%0A  public String getResponseHeader(String name) %7B%0A    return con.getHeaderField(name);%0A  %7D%0A%0A  @Override%0A  public Map%3CString, List%3CString%3E%3E getResponseHeaderFields() %7B%0A    return con.getHeaderFields();%0A  %7D%0A%0A  @Override%0A  public void disconnect() %7B%0A    con.disconnect();%0A  %7D%0A%7D%0A

Add HttpResponseImpl