* New public function dulwich.pack.write_pack_header. (Dave Borowitz)
+ * Distinguish between missing files and read errors in HTTP server.
+ (Dave Borowitz)
+
+ TESTS
+
+ * Use GitFile when modifying packed-refs in tests. (Dave Borowitz)
+
API CHANGES
* ObjectStore.iter_tree_contents now walks contents in depth-first, sorted
HTTP_OK,
HTTP_NOT_FOUND,
HTTP_FORBIDDEN,
+ HTTP_ERROR,
send_file,
get_info_refs,
handle_service_request,
f = TestFile()
list(send_file(self._req, f, 'text/plain'))
- self.assertEquals(HTTP_NOT_FOUND, self._status)
+ self.assertEquals(HTTP_ERROR, self._status)
self.assertTrue(f.closed)
def test_get_info_refs(self):
HTTP_OK = '200 OK'
HTTP_NOT_FOUND = '404 Not Found'
HTTP_FORBIDDEN = '403 Forbidden'
+HTTP_ERROR = '500 Internal Server Error'
def date_time_string(timestamp=None):
f.close()
except IOError:
f.close()
- yield req.not_found('Error reading file')
+ yield req.error('Error reading file')
except:
f.close()
raise
try:
data = object_store[sha].as_legacy_object()
except IOError:
- yield req.not_found('Error reading object')
+ yield req.error('Error reading object')
req.cache_forever()
req.respond(HTTP_OK, 'application/x-git-loose-object')
yield data
self.respond(HTTP_FORBIDDEN, 'text/plain')
return message
+ def error(self, message):
+ """Begin a HTTP 500 response and return the text of a message."""
+ self._cache_headers = []
+ logger.error('Error: %s', message)
+ self.respond(HTTP_ERROR, 'text/plain')
+ return message
+
def nocache(self):
"""Set the response to never be cached by the client."""
self._cache_headers = [