/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/HttpServer.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-12-13 05:52:27 UTC
  • mfrom: (2180.1.2 revert-missing)
  • Revision ID: pqm@pqm.ubuntu.com-20061213055227-6159e82aef3f15a6
Handle short http reads better.  (Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
            file = open(path, 'rb')
160
160
        except IOError:
161
161
            self.send_error(404, "File not found")
162
 
            return None
 
162
            return
163
163
 
164
164
        file_size = os.fstat(file.fileno())[6]
165
165
        tail, ranges = self.parse_ranges(ranges_header_value)
176
176
                    ranges_valid = False
177
177
                    break
178
178
        if not ranges_valid:
179
 
            # RFC2616 14-16 says that invalid Range headers
180
 
            # should be ignored and in that case, the whole file
181
 
            # should be returned as if no Range header was
182
 
            # present
183
 
            file.close() # Will be reopened by the following call
184
 
            return SimpleHTTPRequestHandler.do_GET(self)
 
179
            # RFC2616 14.35 says that invalid Range headers must
 
180
            # be ignored. If they are, the whole file should be
 
181
            # returned as though no Range header was present. If
 
182
            # they aren't, the server should return a 416 error.
 
183
            # FIXME: per 14.35, ranges are only invalid if start > end.
 
184
            # end values should be truncated to file_size -1 if they exceed it.
 
185
            # only start values >= file_size should produce a 416.
 
186
            file.close()
 
187
            self.send_error(416, "Requested range not satisfiable")
 
188
            return
185
189
 
186
190
        if len(ranges) == 1:
187
191
            (start, end) = ranges[0]