'Open a connection to the Solr endpoint, and send the documents
for indexing. Multiple requests are sent if a large number of documents
are being sent (see chunk_xml())
Raises SearchHTTPError if the endpoint indicates a failure'

def send_documents(self, docs):

    core = getattr(g, 'solr_core', 'collection1')
    responses = []
    connection = httplib.HTTPConnection(self.solr_host, self.solr_port)
    chunker = chunk_xml(docs)
    headers = {}
    headers['Content-Type'] = 'application/xml'
    try:
        for data in chunker:
            if getattr(g, 'solr_version', '1').startswith('4'):
                connection.request('POST', ('/solr/%s/update/' % core), data, headers)
            else:
                connection.request('POST', '/solr/update/', data, headers)
            response = connection.getresponse()
            if (200 <= response.status < 300):
                responses.append(response.read())
            else:
                raise SearchHTTPError(response.status, response.reason, response.read())
    finally:
        connection.close()
    return responses
