~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Handlers for HTTP Responses.
18
18
 
91
91
 
92
92
    def set_boundary(self, boundary):
93
93
        """Define the boundary used in a multi parts message.
94
 
        
 
94
 
95
95
        The file should be at the beginning of the body, the first range
96
96
        definition is read and taken into account.
97
97
        """
109
109
            # To be on the safe side we allow it before any boundary line
110
110
            boundary_line = self._file.readline()
111
111
 
 
112
        if boundary_line == '':
 
113
            # A timeout in the proxy server caused the response to end early.
 
114
            # See launchpad bug 198646.
 
115
            raise errors.HttpBoundaryMissing(
 
116
                self._path,
 
117
                self._boundary)
 
118
 
112
119
        if boundary_line != '--' + self._boundary + '\r\n':
113
120
            # rfc822.unquote() incorrectly unquotes strings enclosed in <>
114
121
            # IIS 6 and 7 incorrectly wrap boundary strings in <>
115
122
            # together they make a beautiful bug, which we will be gracious
116
123
            # about here
117
 
            if (self._unquote_boundary(boundary_line) != 
 
124
            if (self._unquote_boundary(boundary_line) !=
118
125
                '--' + self._boundary + '\r\n'):
119
126
                raise errors.InvalidHttpResponse(
120
127
                    self._path,
288
295
    :param msg: An HTTPMessage containing the headers for the response
289
296
    :param data: A file-like object that can be read() to get the
290
297
                 requested data
291
 
    :return: A file-like object that can seek()+read() the 
 
298
    :return: A file-like object that can seek()+read() the
292
299
             ranges indicated by the headers.
293
300
    """
294
301
    rfile = RangeFile(url, data)