function processData (data, args, options, stream) {
  const item = !data.length ? data : data.shift()

  // fix for pause/resume downloads
  const headers = Object.assign(
    { Host: new URL(item.url).hostname },
    data.http_headers
  )

  if (options && options.start > 0 && options.end > 0) {
    headers.Range = 'bytes=' + options.start + '-' + options.end
  } else if (typeof item.filesize === 'number') {
    headers.Range = 'bytes=0-' + item.filesize
  }

  const proxyArgIndex = (args && args.indexOf('--proxy')) || -1
  const req = got.stream({
    url: item.url,
    headers: headers,
    ecdhCurve: 'auto',
    timeout: 30000,
    ...(proxyArgIndex > -1 && { proxy: args[proxyArgIndex + 1] })
  })

  req.on('response', function response (res) {
    const size = parseInt(res.headers['content-length'], 10)
    if (size) item.size = size

    if (options && options.start > 0 && res.statusCode === 416) {
      // the file that is being resumed is complete.
      return stream.emit('complete', item)
    }

    if (res.statusCode !== 200 && res.statusCode !== 206) {
      return stream.emit('error', new Error('status code ' + res.statusCode))
    }

    stream.emit('info', item)

    stream.on('end', function end () {
      if (data.length) stream.emit('next', data)
    })
  })

  return stream.resolve(req)
}
Processes data

@param {Object} data
@param {Object} options
@param {Object} stream