private void readResponseHeaders(State state,InnerState innerState,HttpResponse response) throws StopRequest {
  Header header=response.getFirstHeader("Content-Disposition");
  if (header != null) {
    innerState.mHeaderContentDisposition=header.getValue();
  }
  header=response.getFirstHeader("Content-Location");
  if (header != null) {
    innerState.mHeaderContentLocation=header.getValue();
  }
  header=response.getFirstHeader("ETag");
  if (header != null) {
    innerState.mHeaderETag=header.getValue();
  }
  String headerTransferEncoding=null;
  header=response.getFirstHeader("Transfer-Encoding");
  if (header != null) {
    headerTransferEncoding=header.getValue();
  }
  String headerContentType=null;
  header=response.getFirstHeader("Content-Type");
  if (header != null) {
    headerContentType=header.getValue();
    if (!headerContentType.equals("application/vnd.android.obb")) {
      throw new StopRequest(DownloaderService.STATUS_FILE_DELIVERED_INCORRECTLY,"file delivered with incorrect Mime type");
    }
  }
  if (headerTransferEncoding == null) {
    header=response.getFirstHeader("Content-Length");
    if (header != null) {
      innerState.mHeaderContentLength=header.getValue();
      long contentLength=Long.parseLong(innerState.mHeaderContentLength);
      if (contentLength != -1 && contentLength != mInfo.mTotalBytes) {
        Log.e(Constants.TAG,"Incorrect file size delivered.");
      }
    }
  }
 else {
    if (Constants.LOGVV) {
      Log.v(Constants.TAG,"ignoring content-length because of xfer-encoding");
    }
  }
  if (Constants.LOGVV) {
    Log.v(Constants.TAG,"Content-Disposition: " + innerState.mHeaderContentDisposition);
    Log.v(Constants.TAG,"Content-Length: " + innerState.mHeaderContentLength);
    Log.v(Constants.TAG,"Content-Location: " + innerState.mHeaderContentLocation);
    Log.v(Constants.TAG,"ETag: " + innerState.mHeaderETag);
    Log.v(Constants.TAG,"Transfer-Encoding: " + headerTransferEncoding);
  }
  boolean noSizeInfo=innerState.mHeaderContentLength == null && (headerTransferEncoding == null || !headerTransferEncoding.equalsIgnoreCase("chunked"));
  if (noSizeInfo) {
    throw new StopRequest(DownloaderService.STATUS_HTTP_DATA_ERROR,"can't know size of download, giving up");
  }
}

private void readResponseHeaders ( State state , InnerState innerState , HttpResponse response ) throws StopRequest { Header header = response . getFirstHeader ( "Content-Disposition" ) ; if ( header != null ) { innerState . mHeaderContentDisposition = header . getValue ( ) ; } header = response . getFirstHeader ( "Content-Location" ) ; if ( header != null ) { innerState . mHeaderContentLocation = header . getValue ( ) ; } header = response . getFirstHeader ( "ETag" ) ; if ( header != null ) { innerState . mHeaderETag = header . getValue ( ) ; } String headerTransferEncoding = null ; header = response . getFirstHeader ( "Transfer-Encoding" ) ; if ( header != null ) { headerTransferEncoding = header . getValue ( ) ; } String headerContentType = null ; header = response . getFirstHeader ( "Content-Type" ) ; if ( header != null ) { headerContentType = header . getValue ( ) ; if ( ! headerContentType . equals ( "application/vnd.android.obb" ) ) { throw new StopRequest ( DownloaderService . STATUS_FILE_DELIVERED_INCORRECTLY , "file delivered with incorrect Mime type" ) ; } } if ( headerTransferEncoding == null ) { header = response . getFirstHeader ( "Content-Length" ) ; if ( header != null ) { innerState . mHeaderContentLength = header . getValue ( ) ; long contentLength = Long . parseLong ( innerState . mHeaderContentLength ) ; if ( contentLength != - 1 && contentLength != mInfo . mTotalBytes ) { Log . e ( Constants . TAG , "Incorrect file size delivered." ) ; } } } else { if ( Constants . LOGVV ) { Log . v ( Constants . TAG , "ignoring content-length because of xfer-encoding" ) ; } } if ( Constants . LOGVV ) { Log . v ( Constants . TAG , "Content-Disposition: " + innerState . mHeaderContentDisposition ) ; Log . v ( Constants . TAG , "Content-Length: " + innerState . mHeaderContentLength ) ; Log . v ( Constants . TAG , "Content-Location: " + innerState . mHeaderContentLocation ) ; Log . v ( Constants . TAG , "ETag: " + innerState . mHeaderETag ) ; Log . v ( Constants . TAG , "Transfer-Encoding: " + headerTransferEncoding ) ; } boolean noSizeInfo = innerState . mHeaderContentLength == null && ( headerTransferEncoding == null || ! headerTransferEncoding . equalsIgnoreCase ( "chunked" ) ) ; if ( noSizeInfo ) { throw new StopRequest ( DownloaderService . STATUS_HTTP_DATA_ERROR , "can't know size of download, giving up" ) ; } }
read headers from the http response and store them into local state .
