Esempio n. 1
0
    def body_stream(self):
        """ stream body """
        if not self.can_read():
            raise AlreadyRead()

        self._already_read = True

        return BodyWrapper(self, self.connection)
Esempio n. 2
0
 def body_string(self, charset=None, unicode_errors="strict"):
     """ return body string, by default in bytestring """
     if self.closed or self.response.body.closed:
         raise AlreadyRead("The response have already been read")
     body = self.response.body.read()
     if charset is not None:
         try:
             body = body.decode(charset, unicode_errors)
         except UnicodeDecodeError:
             pass
     self.close()
     return body
Esempio n. 3
0
    def body_string(self, charset=None, unicode_errors="strict"):
        """ return body string, by default in bytestring """

        if not self.can_read():
            raise AlreadyRead()

        body = self._body.read()
        self._already_read = True

        self.connection.release(self.should_close)

        if charset is not None:
            try:
                body = body.decode(charset, unicode_errors)
            except UnicodeDecodeError:
                pass
        return body
Esempio n. 4
0
 def body_stream(self):
     """ return full body stream """
     if self.closed or self.response.body.closed:
         raise AlreadyRead("The response have already been read")
     return self.response.body