diff --git a/src/sugar/network.py b/src/sugar/network.py
index 34d496c..77672ef 100644
|
a
|
b
|
|
| 97 | 97 | """Serve a GET request.""" |
| 98 | 98 | self._file = self.send_head() |
| 99 | 99 | if self._file: |
| 100 | | self._srcid = gobject.io_add_watch(self.wfile, gobject.IO_OUT | |
| 101 | | gobject.IO_ERR, |
| 102 | | self._send_next_chunk) |
| 103 | | else: |
| 104 | | self._cleanup() |
| 105 | | |
| 106 | | def _send_next_chunk(self, source, condition): |
| 107 | | if condition & gobject.IO_ERR: |
| 108 | | self._cleanup() |
| 109 | | return False |
| 110 | | if not (condition & gobject.IO_OUT): |
| | 100 | data = self._file.read(self.CHUNK_SIZE) |
| | 101 | while data: |
| | 102 | os.write(self.wfile.fileno(), data) |
| | 103 | data = self._file.read(self.CHUNK_SIZE) |
| 111 | 104 | self._cleanup() |
| 112 | | return False |
| 113 | | data = self._file.read(self.CHUNK_SIZE) |
| 114 | | count = os.write(self.wfile.fileno(), data) |
| 115 | | if count != len(data) or len(data) != self.CHUNK_SIZE: |
| | 105 | else: |
| 116 | 106 | self._cleanup() |
| 117 | | return False |
| 118 | | return True |
| 119 | 107 | |
| 120 | 108 | def _cleanup(self): |
| 121 | 109 | if self._file: |