comparison mercurial/httpclient/__init__.py @ 14341:5c3de67e7402

httpclient: import revision b8c3511a8cae from py-nonblocking-http Fixes issues with SSL_ERROR_WANT_READ incorrectly breaking the response read.
author Augie Fackler <durin42@gmail.com>
date Thu, 12 May 2011 10:48:31 -0500
parents 9adbb5ef0964
children a75e0f4ba0ab
comparison
equal deleted inserted replaced
14340:defa319d8bb7 14341:5c3de67e7402
163 if not (self.complete() or 163 if not (self.complete() or
164 (self._content_len == _LEN_CLOSE_IS_END and self._body)): 164 (self._content_len == _LEN_CLOSE_IS_END and self._body)):
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 logger.info('cl: %r body: %r', self._content_len, self._body) 167 logger.info('cl: %r body: %r', self._content_len, self._body)
168 data = self.sock.recv(INCOMING_BUFFER_SIZE) 168 try:
169 data = self.sock.recv(INCOMING_BUFFER_SIZE)
170 except socket.sslerror, e:
171 if e.args[0] != socket.SSL_ERROR_WANT_READ:
172 raise
173 logger.debug('SSL_WANT_READ in _select, should retry later')
174 return True
169 logger.debug('response read %d data during _select', len(data)) 175 logger.debug('response read %d data during _select', len(data))
170 if not data: 176 if not data:
171 if not self.headers: 177 if not self.headers:
172 self._load_response(self._end_headers) 178 self._load_response(self._end_headers)
173 self._content_len = 0 179 self._content_len = 0
543 was_first = first 549 was_first = first
544 550
545 # incoming data 551 # incoming data
546 if r: 552 if r:
547 try: 553 try:
548 data = r[0].recv(INCOMING_BUFFER_SIZE) 554 try:
555 data = r[0].recv(INCOMING_BUFFER_SIZE)
556 except socket.sslerror, e:
557 if e.args[0] != socket.SSL_ERROR_WANT_READ:
558 raise
559 logger.debug(
560 'SSL_WANT_READ while sending data, retrying...')
561 continue
549 if not data: 562 if not data:
550 logger.info('socket appears closed in read') 563 logger.info('socket appears closed in read')
551 outgoing_headers = body = None 564 outgoing_headers = body = None
552 break 565 break
553 if response is None: 566 if response is None: