# File lib/taps/data_stream.rb, line 165
  def fetch_from_resource(resource, headers)
    res = nil
    log.debug "DataStream#fetch_from_resource state -> #{state.inspect}"
    state[:chunksize] = Taps::Utils.calculate_chunksize(state[:chunksize]) do |c|
      state[:chunksize] = c.to_i
      res = resource.post({:state => OkJson.encode(self.to_hash)}, headers)
    end

    begin
      params = Taps::Multipart.parse(res)
      params[:json] = self.class.parse_json(params[:json]) if params.has_key?(:json)
      return params
    rescue OkJson::Parser
      raise Taps::CorruptedData.new("Invalid OkJson Received")
    end
  end