/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: Martin Pool
  • Date: 2008-06-18 05:35:02 UTC
  • mto: This revision was merged to the branch mainline in revision 3510.
  • Revision ID: mbp@sourcefrog.net-20080618053502-9ogi5d5tx7w5ybf6
Change stray pdb calls to exceptions

Show diffs side-by-side

added added

removed removed

Lines of Context:
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Handlers for HTTP Responses.
18
18
 
24
24
 
25
25
import httplib
26
26
from cStringIO import StringIO
27
 
import rfc822
28
27
 
29
28
from bzrlib import (
30
29
    errors,
91
90
 
92
91
    def set_boundary(self, boundary):
93
92
        """Define the boundary used in a multi parts message.
94
 
 
 
93
        
95
94
        The file should be at the beginning of the body, the first range
96
95
        definition is read and taken into account.
97
96
        """
108
107
            # string entity.
109
108
            # To be on the safe side we allow it before any boundary line
110
109
            boundary_line = self._file.readline()
111
 
 
112
110
        if boundary_line != '--' + self._boundary + '\r\n':
113
 
            # rfc822.unquote() incorrectly unquotes strings enclosed in <>
114
 
            # IIS 6 and 7 incorrectly wrap boundary strings in <>
115
 
            # together they make a beautiful bug, which we will be gracious
116
 
            # about here
117
 
            if (self._unquote_boundary(boundary_line) !=
118
 
                '--' + self._boundary + '\r\n'):
119
 
                raise errors.InvalidHttpResponse(
120
 
                    self._path,
121
 
                    "Expected a boundary (%s) line, got '%s'"
122
 
                    % (self._boundary, boundary_line))
123
 
 
124
 
    def _unquote_boundary(self, b):
125
 
        return b[:2] + rfc822.unquote(b[2:-2]) + b[-2:]
 
111
            raise errors.InvalidHttpResponse(
 
112
                self._path,
 
113
                "Expected a boundary (%s) line, got '%s'" % (self._boundary,
 
114
                                                             boundary_line))
126
115
 
127
116
    def read_range_definition(self):
128
117
        """Read a new range definition in a multi parts message.
288
277
    :param msg: An HTTPMessage containing the headers for the response
289
278
    :param data: A file-like object that can be read() to get the
290
279
                 requested data
291
 
    :return: A file-like object that can seek()+read() the
 
280
    :return: A file-like object that can seek()+read() the 
292
281
             ranges indicated by the headers.
293
282
    """
294
283
    rfile = RangeFile(url, data)