code: def _get_headers(self, resource):
          
  
          # If the resource is a file we just open it up with the csv
          # reader (after being sure we're reading from the beginning
          # of the file
          if type(resource) == file:
              resource.seek(0)
              reader = csv.reader(resource)
          # If the resource is a basestring it is either a url or a file
          # location, so similarly to the specification mechanism we either
          # access it with an HTTP get request or by opening the file.
          elif isinstance(resource, basestring):
              result = six.moves.urllib.parse.urlparse(resource)
              if result.scheme in ['http', 'https']:
                  with closing(requests.get(resource, stream=True)) as response:
                      # Headers are alway the first row of a CSV file
                      # so it's enought to just get the first line and
                      # hopefully save bandwidth
                      header_row = response.iter_lines().next()
              else:
                  # It may seem weird to open up a csv file, read its header row
                  # and then StringIO that into a new csv reader but this file
                  # we want to close and we want the same interface for all
                  with open(resource) as resource_file:
                      reader = csv.reader(resource_file)
                      header_row = reader.next()
  
              reader = csv.reader(cStringIO.StringIO(header_row))
          else:
              raise IOError('Resource type not supported')
          return reader.next()
docs: Get CSV file headers from the provided resource.