| | |
| | | */ |
| | | protected void serveFile(HttpExchange e, File file) throws IOException { |
| | | if (file.exists()) { |
| | | OutputStream os = e.getResponseBody(); |
| | | setHeaders(e, file); |
| | | e.sendResponseHeaders(SC_OK, file.length()); |
| | | if(HTTP_GET.equalsIgnoreCase(e.getRequestMethod())) { |
| | | InputStream in = new FileInputStream(file); |
| | | OutputStream os = e.getResponseBody(); |
| | | int b = in.read(); |
| | | while (b > -1) { |
| | | os.write(b); |
| | |
| | | */ |
| | | protected void serveFileParts(HttpExchange e, File file) throws IOException { |
| | | if (file.exists()) { |
| | | InputStream is = new FileInputStream(file); |
| | | OutputStream os = e.getResponseBody(); |
| | | setHeaders(e, file); |
| | | long responseLength = 0; |
| | | long start = 0; |
| | |
| | | } |
| | | e.sendResponseHeaders(SC_PARTIAL_CONTENT, responseLength); |
| | | if(HTTP_GET.equalsIgnoreCase(e.getRequestMethod())) { |
| | | InputStream is = new FileInputStream(file); |
| | | OutputStream os = e.getResponseBody(); |
| | | if (start > 0) { |
| | | is.skip(start); |
| | | } |