~ubuntu-branches/ubuntu/trusty/swift/trusty-updates

« back to all changes in this revision

Viewing changes to swift/common/bufferedhttp.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-01-28 09:40:30 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20130128094030-aetz57x2qz9ye2d4
Tags: 1.7.6-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
    :param ssl: set True if SSL should be used (default: False)
127
127
    :returns: HTTPConnection object
128
128
    """
129
 
    if not port:
130
 
        port = 443 if ssl else 80
131
 
    if ssl:
132
 
        conn = HTTPSConnection('%s:%s' % (ipaddr, port))
133
 
    else:
134
 
        conn = BufferedHTTPConnection('%s:%s' % (ipaddr, port))
135
129
    if isinstance(path, unicode):
136
130
        try:
137
131
            path = path.encode("utf-8")
138
132
        except UnicodeError:
139
133
            pass   # what should I do?
140
134
    path = quote('/' + device + '/' + str(partition) + path)
141
 
    if query_string:
142
 
        path += '?' + query_string
143
 
    conn.path = path
144
 
    conn.putrequest(method, path, skip_host=(headers and 'Host' in headers))
145
 
    if headers:
146
 
        for header, value in headers.iteritems():
147
 
            conn.putheader(header, str(value))
148
 
    conn.endheaders()
149
 
    return conn
 
135
    return http_connect_raw(
 
136
        ipaddr, port, method, path, headers, query_string, ssl)
150
137
 
151
138
 
152
139
def http_connect_raw(ipaddr, port, method, path, headers=None,