| 377 | self.charset = "utf-8" |
| 378 | |
| 379 | def content(self): |
| 380 | if self._content: |
| 381 | return self._content |
| 382 | encode = self.rep.msg.get('content-encoding', None) |
| 383 | try: |
| 384 | body = self.rep.read() |
| 385 | except socket.timeout: |
| 386 | body = b'' |
| 387 | if encode == 'gzip': |
| 388 | body = gzip.decompress(body) |
| 389 | elif encode == 'deflate': |
| 390 | try: |
| 391 | body = zlib.decompress(body, -zlib.MAX_WBITS) |
| 392 | except: |
| 393 | body = zlib.decompress(body) |
| 394 | # redirect = self.rep.msg.get('location', None) # handle 301/302 |
| 395 | self._content = body |
| 396 | return body |
| 397 | |
| 398 | def text(self): |
| 399 | ''' |