private void processResponseHeaders(State state,InnerState innerState,HttpResponse response) throws StopRequest {
  if (innerState.mContinuingDownload) {
    return;
  }
  readResponseHeaders(state,innerState,response);
  try {
    state.mFilename=mService.generateSaveFile(mInfo.mFileName,mInfo.mTotalBytes);
  }
 catch (  DownloaderService.GenerateSaveFileError exc) {
    throw new StopRequest(exc.mStatus,exc.mMessage);
  }
  try {
    state.mStream=new FileOutputStream(state.mFilename);
  }
 catch (  FileNotFoundException exc) {
    File pathFile=new File(Helpers.getSaveFilePath(mService));
    try {
      if (pathFile.mkdirs()) {
        state.mStream=new FileOutputStream(state.mFilename);
      }
    }
 catch (    Exception ex) {
      throw new StopRequest(DownloaderService.STATUS_FILE_ERROR,"while opening destination file: " + exc.toString(),exc);
    }
  }
  if (Constants.LOGV) {
    Log.v(Constants.TAG,"writing " + mInfo.mUri + " to "+ state.mFilename);
  }
  updateDatabaseFromHeaders(state,innerState);
  checkConnectivity(state);
}

private void processResponseHeaders ( State state , InnerState innerState , HttpResponse response ) throws StopRequest { if ( innerState . mContinuingDownload ) { return ; } readResponseHeaders ( state , innerState , response ) ; try { state . mFilename = mService . generateSaveFile ( mInfo . mFileName , mInfo . mTotalBytes ) ; } catch ( DownloaderService . GenerateSaveFileError exc ) { throw new StopRequest ( exc . mStatus , exc . mMessage ) ; } try { state . mStream = new FileOutputStream ( state . mFilename ) ; } catch ( FileNotFoundException exc ) { File pathFile = new File ( Helpers . getSaveFilePath ( mService ) ) ; try { if ( pathFile . mkdirs ( ) ) { state . mStream = new FileOutputStream ( state . mFilename ) ; } } catch ( Exception ex ) { throw new StopRequest ( DownloaderService . STATUS_FILE_ERROR , "while opening destination file: " + exc . toString ( ) , exc ) ; } } if ( Constants . LOGV ) { Log . v ( Constants . TAG , "writing " + mInfo . mUri + " to " + state . mFilename ) ; } updateDatabaseFromHeaders ( state , innerState ) ; checkConnectivity ( state ) ; }
read http response headers and take appropriate action , including setting up the destination file and updating the database .
