/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/response.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from __future__ import absolute_import
25
25
 
26
26
import os
27
 
try:
28
 
    import http.client as http_client
29
 
except ImportError:  # python < 3
30
 
    import httplib as http_client
31
 
try:
32
 
    import email.utils as email_utils
33
 
except ImportError:  # python < 3
34
 
    import rfc822 as email_utils
 
27
import httplib
 
28
from cStringIO import StringIO
 
29
import rfc822
35
30
 
36
 
from ... import (
 
31
from bzrlib import (
37
32
    errors,
38
33
    osutils,
39
34
    )
40
 
from ...sixish import (
41
 
    BytesIO,
42
 
    )
43
35
 
44
36
 
45
37
class ResponseFile(object):
129
121
 
130
122
    # in _checked_read() below, we may have to discard several MB in the worst
131
123
    # case. To avoid buffering that much, we read and discard by chunks
132
 
    # instead. The underlying file is either a socket or a BytesIO, so reading
 
124
    # instead. The underlying file is either a socket or a StringIO, so reading
133
125
    # 8k chunks should be fine.
134
126
    _discarded_buf_size = 8192
135
127
 
186
178
                self._boundary)
187
179
 
188
180
        if boundary_line != '--' + self._boundary + '\r\n':
189
 
            # email_utils.unquote() incorrectly unquotes strings enclosed in <>
 
181
            # rfc822.unquote() incorrectly unquotes strings enclosed in <>
190
182
            # IIS 6 and 7 incorrectly wrap boundary strings in <>
191
183
            # together they make a beautiful bug, which we will be gracious
192
184
            # about here
198
190
                    % (self._boundary, boundary_line))
199
191
 
200
192
    def _unquote_boundary(self, b):
201
 
        return b[:2] + email_utils.unquote(b[2:-2]) + b[-2:]
 
193
        return b[:2] + rfc822.unquote(b[2:-2]) + b[-2:]
202
194
 
203
195
    def read_range_definition(self):
204
196
        """Read a new range definition in a multi parts message.
206
198
        Parse the headers including the empty line following them so that we
207
199
        are ready to read the data itself.
208
200
        """
209
 
        self._headers = http_client.HTTPMessage(self._file, seekable=0)
 
201
        self._headers = httplib.HTTPMessage(self._file, seekable=0)
210
202
        # Extract the range definition
211
203
        content_range = self._headers.getheader('content-range', None)
212
204
        if content_range is None:
297
289
                    % (size, self._start, self._size))
298
290
 
299
291
        # read data from file
300
 
        buf = BytesIO()
 
292
        buf = StringIO()
301
293
        limited = size
302
294
        if self._size > 0:
303
295
            # Don't read past the range definition