mercurial/httpclient/__init__.py
changeset 25660 328739ea70c3
parent 24306 6ddc86eedc3b
child 27601 1ad9da968a2e
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
   164             if not self.complete():
   164             if not self.complete():
   165                 logger.info('timed out with timeout of %s', self._timeout)
   165                 logger.info('timed out with timeout of %s', self._timeout)
   166                 raise HTTPTimeoutException('timeout reading data')
   166                 raise HTTPTimeoutException('timeout reading data')
   167         try:
   167         try:
   168             data = self.sock.recv(INCOMING_BUFFER_SIZE)
   168             data = self.sock.recv(INCOMING_BUFFER_SIZE)
   169         except socket.sslerror, e:
   169         except socket.sslerror as e:
   170             if e.args[0] != socket.SSL_ERROR_WANT_READ:
   170             if e.args[0] != socket.SSL_ERROR_WANT_READ:
   171                 raise
   171                 raise
   172             logger.debug('SSL_ERROR_WANT_READ in _select, should retry later')
   172             logger.debug('SSL_ERROR_WANT_READ in _select, should retry later')
   173             return True
   173             return True
   174         logger.debug('response read %d data during _select', len(data))
   174         logger.debug('response read %d data during _select', len(data))
   553             # incoming data
   553             # incoming data
   554             if r:
   554             if r:
   555                 try:
   555                 try:
   556                     try:
   556                     try:
   557                         data = r[0].recv(INCOMING_BUFFER_SIZE)
   557                         data = r[0].recv(INCOMING_BUFFER_SIZE)
   558                     except socket.sslerror, e:
   558                     except socket.sslerror as e:
   559                         if e.args[0] != socket.SSL_ERROR_WANT_READ:
   559                         if e.args[0] != socket.SSL_ERROR_WANT_READ:
   560                             raise
   560                             raise
   561                         logger.debug('SSL_ERROR_WANT_READ while sending '
   561                         logger.debug('SSL_ERROR_WANT_READ while sending '
   562                                      'data, retrying...')
   562                                      'data, retrying...')
   563                         continue
   563                         continue
   608                     # pylint: disable=W0212
   608                     # pylint: disable=W0212
   609                     response._load_response(data)
   609                     response._load_response(data)
   610                     # Jump to the next select() call so we load more
   610                     # Jump to the next select() call so we load more
   611                     # data if the server is still sending us content.
   611                     # data if the server is still sending us content.
   612                     continue
   612                     continue
   613                 except socket.error, e:
   613                 except socket.error as e:
   614                     if e[0] != errno.EPIPE and not was_first:
   614                     if e[0] != errno.EPIPE and not was_first:
   615                         raise
   615                         raise
   616 
   616 
   617             # outgoing data
   617             # outgoing data
   618             if w and out:
   618             if w and out:
   631                         if chunked:
   631                         if chunked:
   632                             out = hex(len(data))[2:] + EOL + data + EOL
   632                             out = hex(len(data))[2:] + EOL + data + EOL
   633                         else:
   633                         else:
   634                             out = data
   634                             out = data
   635                     amt = w[0].send(out)
   635                     amt = w[0].send(out)
   636                 except socket.error, e:
   636                 except socket.error as e:
   637                     if e[0] == socket.SSL_ERROR_WANT_WRITE and self.ssl:
   637                     if e[0] == socket.SSL_ERROR_WANT_WRITE and self.ssl:
   638                         # This means that SSL hasn't flushed its buffer into
   638                         # This means that SSL hasn't flushed its buffer into
   639                         # the socket yet.
   639                         # the socket yet.
   640                         # TODO: find a way to block on ssl flushing its buffer
   640                         # TODO: find a way to block on ssl flushing its buffer
   641                         # similar to selecting on a raw socket.
   641                         # similar to selecting on a raw socket.