/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 breezy/transport/http/response.py

  • Committer: Jelmer Vernooij
  • Date: 2020-02-21 04:28:46 UTC
  • mfrom: (7494 work)
  • mto: This revision was merged to the branch mainline in revision 7496.
  • Revision ID: jelmer@jelmer.uk-20200221042846-r8lzqu0jetkw772i
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
responses.
22
22
"""
23
23
 
24
 
from __future__ import absolute_import
25
 
 
26
24
import cgi
 
25
from io import BytesIO
27
26
import os
28
 
try:
29
 
    import http.client as http_client
30
 
except ImportError:  # python < 3
31
 
    import httplib as http_client
32
 
try:
33
 
    import email.utils as email_utils
34
 
except ImportError:  # python < 3
35
 
    import rfc822 as email_utils
 
27
import http.client as http_client
 
28
import email.utils as email_utils
36
29
 
37
30
from ... import (
38
31
    errors,
39
32
    osutils,
40
33
    )
41
 
from ...sixish import (
42
 
    BytesIO,
43
 
    PY3,
44
 
    )
45
34
 
46
35
 
47
36
class ResponseFile(object):
80
69
        :param size:  The number of bytes to read.  Leave unspecified or pass
81
70
            -1 to read to EOF.
82
71
        """
83
 
        if size is None and not PY3:
84
 
            size = -1
85
72
        data = self._file.read(size)
86
73
        self._pos += len(data)
87
74
        return data
220
207
        Parse the headers including the empty line following them so that we
221
208
        are ready to read the data itself.
222
209
        """
223
 
        if PY3:
224
 
            self._headers = http_client.parse_headers(self._file)
225
 
        else:
226
 
            self._headers = http_client.HTTPMessage(self._file, seekable=0)
 
210
        self._headers = http_client.parse_headers(self._file)
227
211
        # Extract the range definition
228
212
        content_range = self._headers.get('content-range', None)
229
213
        if content_range is None: