| | |
| | | @Override |
| | | public void handle(HttpExchange e) throws IOException { |
| | | String ctxPath = e.getHttpContext().getPath(); |
| | | logger.finer(ctxPath); |
| | | String uriPath = e.getRequestURI().getPath(); |
| | | logger.finer(uriPath); |
| | | logger.info(uriPath); |
| | | String fName = uriPath.substring(ctxPath.length()); |
| | | logger.finer(fName); |
| | | |
| | | Headers headers = e.getRequestHeaders(); |
| | | Set keys = headers.keySet(); |
| | | Iterator i = keys.iterator(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | while(i.hasNext()) { |
| | | String key = i.next().toString(); |
| | | sb.append(" "); |
| | | sb.append(key); |
| | | sb.append(": "); |
| | | sb.append(headers.getFirst(key)); |
| | | sb.append("\r\n"); |
| | | } |
| | | logger.finer(sb.toString()); |
| | | |
| | | if (fName.startsWith(".")) { |
| | | sendNotFound(e, fName); |
| | | } else { |
| | | //Headers headers = e.getRequestHeaders(); |
| | | Headers headers = e.getRequestHeaders(); |
| | | if (headers.containsKey(RANGE_HEADER)) { |
| | | logger.finer("has range header"); |
| | | serveFileParts(e, new File(basePath, fName)); |
| | | } else { |
| | | logger.finer("no range header"); |
| | | if (fName.endsWith("/")) { |
| | | fName += "index.html"; |
| | | } |
| | |
| | | sb.append("/"); |
| | | sb.append(file.length()); |
| | | resHeaders.add(CONTENT_RANGE_HEADER, sb.toString()); |
| | | logger.info(sb.toString()); |
| | | responseLength += (end - start); |
| | | logger.info("responseLength: " + responseLength); |
| | | } |
| | | resHeaders.add(CONTENT_TYPE, "video/mp4"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); |
| | |
| | | private RangeGroup parseRanges(HttpExchange e, File file) { |
| | | RangeGroup ranges = new RangeGroup(); |
| | | String rangeHeader = e.getRequestHeaders().get(RANGE_HEADER).toString(); |
| | | logger.info(rangeHeader); |
| | | |
| | | /* |
| | | Inhalt des Range-Headers von nicht benoetigten Angaben befreien |
| | | |
| | |
| | | Ziffern 0-9, Bindestrich oder Komma sind. |
| | | */ |
| | | rangeHeader = rangeHeader.replaceAll("[^\\d-,]", ""); |
| | | logger.info(rangeHeader); |
| | | |
| | | /* |
| | | Die Ranges ermitteln. |