def get_object(resource, type, id, location = false) #:yields: data_object
      header = {
        'Accept' => mimemap.keys.join(',')
      }

      data = {
        'Resource' => resource,
        'Type'     => type,
        'ID'       => id,
        'Location' => location ? '1' : '0'
      }

      response = request(@urls.objects, data, header)
      results = block_given? ? 0 : []

      if response['content-type'] && response['content-type'].include?('text/xml')
        # This probably means that there was an error.
        # Response parser will likely raise an exception.
        # TODO: test this
        rr = ResponseDocument.safe_parse(response.body).validate!.to_transaction
        return rr
      elsif response['content-type'] && response['content-type'].include?('multipart/parallel')
        content_type = process_content_type(response['content-type'])

#        TODO: log this
#        puts "SPLIT ON #{content_type['boundary']}"
        boundary = content_type['boundary']
        if boundary =~ /\s*'([^']*)\s*/
          boundary = $1
        end
        parts = response.body.split("\r\n--#{boundary}")

        parts.shift # Get rid of the initial boundary

#        TODO: log this
#        puts "GOT PARTS #{parts.length}"

        parts.each do |part|
          (raw_header, raw_data) = part.split("\r\n\r\n")

#          TODO: log this
#          puts raw_data.nil?
          next unless raw_data

          data_header = process_header(raw_header)
          data_object = DataObject.new(data_header, raw_data)

          if block_given?
            yield data_object
            results += 1
          else
            results << data_object
          end
        end
      else
        info = {
          'content-type' => response['content-type'], # Compatibility shim.  Deprecated.
          'Content-Type' => response['content-type'],
          'Object-ID'    => response['Object-ID'],
          'Content-ID'   => response['Content-ID']
        }

        if response['Transfer-Encoding'].to_s.downcase == "chunked" || response['Content-Length'].to_i > 100 then
          data_object = DataObject.new(info, response.body)
          if block_given?
            yield data_object
            results += 1
          else
            results << data_object
          end
        end
      end

      results
    end
def get_object(resource, type, id, location = false) #:yields: data_object
      header = {
        'Accept' => mimemap.keys.join(',')
      }

      data = {
        'Resource' => resource,
        'Type'     => type,
        'ID'       => id,
        'Location' => location ? '1' : '0'
      }

      response = request(@urls.objects, data, header)
      results = block_given? ? 0 : []

      if response['content-type'] && response['content-type'].include?('text/xml')
        # This probably means that there was an error.
        # Response parser will likely raise an exception.
        # TODO: test this
        rr = ResponseDocument.safe_parse(response.body).validate!.to_transaction
        return rr
      elsif response['content-type'] && response['content-type'].include?('multipart/parallel')
        content_type = process_content_type(response['content-type'])

#        TODO: log this
#        puts "SPLIT ON #{content_type['boundary']}"
        boundary = content_type['boundary']
        if boundary =~ /\s*'([^']*)\s*/
          boundary = $1
        end
        parts = response.body.split("\r\n--#{boundary}")

        parts.shift # Get rid of the initial boundary

#        TODO: log this
#        puts "GOT PARTS #{parts.length}"

        parts.each do |part|
          (raw_header, raw_data) = part.split("\r\n\r\n")

#          TODO: log this
#          puts raw_data.nil?
          next unless raw_data

          data_header = process_header(raw_header)
          data_object = DataObject.new(data_header, raw_data)

          if block_given?
            yield data_object
            results += 1
          else
            results << data_object
          end
        end
      else
        info = {
          'content-type' => response['content-type'], # Compatibility shim.  Deprecated.
          'Content-Type' => response['content-type'],
          'Object-ID'    => response['Object-ID'],
          'Content-ID'   => response['Content-ID']
        }

        if response['Transfer-Encoding'].to_s.downcase == "chunked" || response['Content-Length'].to_i > 100 then
          data_object = DataObject.new(info, response.body)
          if block_given?
            yield data_object
            results += 1
          else
            results << data_object
          end
        end
      end

      results
    end
Performs a GetObject transaction on the server. For details on the arguments, please see
 the RETS specification on GetObject requests.

 This method either returns an Array of DataObject instances, or yields each DataObject
 as it is created. If a block is given, the number of objects yielded is returned.

 TODO: how much of this could we move over to WEBrick::HTTPRequest#parse?