'Post a query to the server, and return a string response.'

def post_to_server(self, data, auth=None):

    if ('name' in data):
        self.announce(('Registering    %s    to    %s' % (data['name'], self.repository)), log.INFO)
    boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
    sep_boundary = ('\n--' + boundary)
    end_boundary = (sep_boundary + '--')
    chunks = []
    for (key, value) in data.items():
        if (type(value) not in (type([]), type(()))):
            value = [value]
        for value in value:
            chunks.append(sep_boundary)
            chunks.append(('\nContent-Disposition:    form-data;    name="%s"' % key))
            chunks.append('\n\n')
            chunks.append(value)
            if (value and (value[(-1)] == '\r')):
                chunks.append('\n')
    chunks.append(end_boundary)
    chunks.append('\n')
    body = []
    for chunk in chunks:
        if isinstance(chunk, unicode):
            body.append(chunk.encode('utf-8'))
        else:
            body.append(chunk)
    body = ''.join(body)
    headers = {'Content-type': ('multipart/form-data;    boundary=%s;    charset=utf-8' % boundary), 'Content-length': str(len(body))}
    req = urllib2.Request(self.repository, body, headers)
    opener = urllib2.build_opener(urllib2.HTTPBasicAuthHandler(password_mgr=auth))
    data = ''
    try:
        result = opener.open(req)
    except urllib2.HTTPError as e:
        if self.show_response:
            data = e.fp.read()
        result = (e.code, e.msg)
    except urllib2.URLError as e:
        result = (500, str(e))
    else:
        if self.show_response:
            data = result.read()
        result = (200, 'OK')
    if self.show_response:
        dashes = ('-' * 75)
        self.announce(('%s%s%s' % (dashes, data, dashes)))
    return result
