/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/_urllib2_wrappers.py

  • Committer: John Arbash Meinel
  • Date: 2010-11-05 20:54:32 UTC
  • mfrom: (5526 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5527.
  • Revision ID: john@arbash-meinel.com-20101105205432-rmyozu8sthyhmri8
Merge bzr.dev to resolve bzr-2.3.txt (aka NEWS)

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
    """
166
166
 
167
167
    # Some responses have bodies in which we have no interest
168
 
    _body_ignored_responses = [301,302, 303, 307, 401, 403, 404]
 
168
    _body_ignored_responses = [301,302, 303, 307, 400, 401, 403, 404, 501]
169
169
 
170
170
    # in finish() below, we may have to discard several MB in the worst
171
171
    # case. To avoid buffering that much, we read and discard by chunks
266
266
    def cleanup_pipe(self):
267
267
        """Read the remaining bytes of the last response if any."""
268
268
        if self._response is not None:
269
 
            pending = self._response.finish()
270
 
            # Warn the user (once)
271
 
            if (self._ranges_received_whole_file is None
272
 
                and self._response.status == 200
273
 
                and pending and pending > self._range_warning_thresold
274
 
                ):
275
 
                self._ranges_received_whole_file = True
276
 
                trace.warning(
277
 
                    'Got a 200 response when asking for multiple ranges,'
278
 
                    ' does your server at %s:%s support range requests?',
279
 
                    self.host, self.port)
 
269
            try:
 
270
                pending = self._response.finish()
 
271
                # Warn the user (once)
 
272
                if (self._ranges_received_whole_file is None
 
273
                    and self._response.status == 200
 
274
                    and pending and pending > self._range_warning_thresold
 
275
                    ):
 
276
                    self._ranges_received_whole_file = True
 
277
                    trace.warning(
 
278
                        'Got a 200 response when asking for multiple ranges,'
 
279
                        ' does your server at %s:%s support range requests?',
 
280
                        self.host, self.port)
 
281
            except socket.error, e:
 
282
                # It's conceivable that the socket is in a bad state here
 
283
                # (including some test cases) and in this case, it doesn't need
 
284
                # cleaning anymore, so no need to fail, we just get rid of the
 
285
                # socket and let callers reconnect
 
286
                if (len(e.args) == 0
 
287
                    or e.args[0] not in (errno.ECONNRESET, errno.ECONNABORTED)):
 
288
                    raise
 
289
                self.close()
280
290
            self._response = None
281
291
        # Preserve our preciousss
282
292
        sock = self.sock
1202
1212
        user = auth.get('user', None)
1203
1213
        password = auth.get('password', None)
1204
1214
        realm = auth['realm']
 
1215
        port = auth.get('port', None)
1205
1216
 
1206
1217
        if user is None:
1207
1218
            user = auth_conf.get_user(auth['protocol'], auth['host'],
1208
 
                                      port=auth['port'], path=auth['path'],
 
1219
                                      port=port, path=auth['path'],
1209
1220
                                      realm=realm, ask=True,
1210
1221
                                      prompt=self.build_username_prompt(auth))
1211
1222
        if user is not None and password is None:
1212
1223
            password = auth_conf.get_password(
1213
 
                auth['protocol'], auth['host'], user, port=auth['port'],
 
1224
                auth['protocol'], auth['host'], user,
 
1225
                port=port,
1214
1226
                path=auth['path'], realm=realm,
1215
1227
                prompt=self.build_password_prompt(auth))
1216
1228