Пример #1
0
 def _read_more(self):
     next_read_size = self._protocol_decoder.next_read_size()
     if next_read_size == 0:
         # a complete request has been read.
         self.finished_reading = True
         self._medium_request.finished_reading()
         return
     bytes = self._medium_request.read_bytes(next_read_size)
     if bytes == '':
         # end of file encountered reading from server
         if 'hpss' in debug.debug_flags:
             mutter('decoder state: buf[:10]=%r, state_accept=%s',
                    self._protocol_decoder._in_buffer[:10],
                    self._protocol_decoder.state_accept.__name__)
         raise errors.ConnectionReset(
             "please check connectivity and permissions",
             "(and try -Dhpss if further diagnosis is required)")
     self._protocol_decoder.accept_bytes(bytes)
Пример #2
0
 def _read_more(self):
     next_read_size = self._protocol_decoder.next_read_size()
     if next_read_size == 0:
         # a complete request has been read.
         self.finished_reading = True
         self._medium_request.finished_reading()
         return
     bytes = self._medium_request.read_bytes(next_read_size)
     if bytes == '':
         # end of file encountered reading from server
         if 'hpss' in debug.debug_flags:
             mutter('decoder state: buf[:10]=%r, state_accept=%s',
                    self._protocol_decoder._get_in_buffer()[:10],
                    self._protocol_decoder.state_accept.__name__)
         raise errors.ConnectionReset(
             "Unexpected end of message. "
             "Please check connectivity and permissions, and report a bug "
             "if problems persist.")
     self._protocol_decoder.accept_bytes(bytes)
Пример #3
0
 def _curl_perform(self, curl, header, more_headers=[]):
     """Perform curl operation and translate exceptions."""
     try:
         # There's no way in http/1.0 to say "must
         # revalidate"; we don't want to force it to always
         # retrieve.  so just turn off the default Pragma
         # provided by Curl.
         headers = [
             'Cache-control: max-age=0', 'Pragma: no-cache',
             'Connection: Keep-Alive'
         ]
         curl.setopt(pycurl.HTTPHEADER, headers + more_headers)
         curl.perform()
     except pycurl.error, e:
         url = curl.getinfo(pycurl.EFFECTIVE_URL)
         trace.mutter('got pycurl error: %s, %s, %s, url: %s ', e[0], e[1],
                      e, url)
         if e[0] in (
                 CURLE_COULDNT_RESOLVE_HOST,
                 CURLE_COULDNT_RESOLVE_PROXY,
                 CURLE_COULDNT_CONNECT,
                 CURLE_FTP_WEIRD_SERVER_REPLY,
                 CURLE_GOT_NOTHING,
                 CURLE_SSL_CACERT,
                 CURLE_SSL_CACERT_BADFILE,
         ):
             raise errors.ConnectionError(
                 'curl connection error (%s)\non %s' % (e[1], url))
         elif e[0] == CURLE_RECV_ERROR:
             raise errors.ConnectionReset(
                 'curl connection error (%s)\non %s' % (e[1], url))
         elif e[0] == CURLE_PARTIAL_FILE:
             # Pycurl itself has detected a short read.  We do not have all
             # the information for the ShortReadvError, but that should be
             # enough
             raise errors.ShortReadvError(
                 url,
                 offset='unknown',
                 length='unknown',
                 actual='unknown',
                 extra='Server aborted the request')
         raise