- protected void handlePROPFIND(HttpExchange exchange) throws IOException {
- String relativePath = HttpServerUtils.relativize(exchange);
-
- DavDepth depth = DavDepth.fromHttpExchange(exchange);
- if (depth == null) {
- // default, as per http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND
- depth = DavDepth.DEPTH_INFINITY;
+ @Override
+ protected void handleGET(HttpExchange exchange, String path) throws IOException {
+ ContentSession session = RemoteAuthUtils.doAs(() -> contentRepository.get(),
+ new RemoteAuthHttpExchange(exchange));
+ if (!session.exists(path)) // not found
+ throw new ContentNotFoundException(session, path);
+ Content content = session.get(path);
+ Optional<Long> size = content.get(DName.getcontentlength, Long.class);
+ try (InputStream in = content.open(InputStream.class)) {
+ exchange.sendResponseHeaders(HttpStatus.OK.getCode(), size.orElse(0l));
+ StreamUtils.copy(in, exchange.getResponseBody());
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot process " + path, e);