~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Michael Ellerman
2
 
#           modified by John Arbash Meinel (Canonical Ltd)
 
1
# Copyright (C) 2006 Canonical Ltd
3
2
#
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
251
250
        try:
252
251
            content_type = headers['Content-Type']
253
252
        except KeyError:
254
 
            raise errors.InvalidHttpContentType(url, '',
255
 
                msg='Missing Content-Type')
 
253
            # When there is no content-type header we treat
 
254
            # the response as being of type 'application/octet-stream' as per
 
255
            # RFC2616 section 7.2.1.
 
256
            # Therefore it is obviously not multipart
 
257
            content_type = 'application/octet-stream'
 
258
            is_multipart = False
 
259
        else:
 
260
            is_multipart = _is_multipart(content_type)
256
261
 
257
 
        if _is_multipart(content_type):
 
262
        if is_multipart:
258
263
            # Full fledged multipart response
259
264
            return HttpMultipartRangeResponse(url, content_type, data)
260
265
        else:
274
279
        return data
275
280
    elif code == 404:
276
281
        raise errors.NoSuchFile(url)
 
282
    elif code == 416:
 
283
        # We don't know which, but one of the ranges we specified
 
284
        # was wrong. So we raise with 0 for a lack of a better
 
285
        # magic value.
 
286
        raise errors.InvalidRange(url,0)
277
287
 
278
288
    # TODO: jam 20060713 Properly handle redirects (302 Found, etc)
279
289
    #       The '_get' code says to follow redirects, we probably