Class FileHandler
- java.lang.Object
-
- de.uhilger.httpserver.base.handler.FileHandler
-
- All Implemented Interfaces:
com.sun.net.httpserver.HttpHandler
- Direct Known Subclasses:
PatternDelegator
public class FileHandler extends Object implements com.sun.net.httpserver.HttpHandler
Die Klasse FileHandler dient zur Auslieferung von Dateiinhalten über HTTP. Für das Streaming über HTTP wird die Auslieferung von Teilinhalten mit dem Accept-Ranges-Header angeboten und via Range-Header unterstützt. (vgl. https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests)- Version:
- 1, 03.06.2021, (seit 25. März 2021)
- Author:
- Ulrich Hilger
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_FILE_BASEstatic StringATTR_WELCOME_FILESstatic StringCONTENT_LENGTHstatic StringCONTENT_RANGE_HEADERstatic StringCONTENT_TYPEstatic StringRANGE_HEADERstatic StringRANGE_PATTERNstatic intSC_FORBIDDENstatic intSC_METHOD_NOT_ALLOWEDstatic intSC_NOT_FOUNDstatic intSC_OKstatic intSC_PARTIAL_CONTENTstatic intSC_UNPROCESSABLE_ENTITYstatic StringSTR_BLANKstatic StringSTR_COMMAstatic StringSTR_DASHstatic StringSTR_DOTstatic StringSTR_SLASHstatic StringWELCOME_FILE
-
Constructor Summary
Constructors Constructor Description FileHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandle(com.sun.net.httpserver.HttpExchange e)Die Datei ermitteln, die sich aus dem angefragten URL ergibt, prüfen, ob die Datei existiert und den Inhalt der Datei abhängig davon, ob ein Range-Header vorhanden ist, ganz oder teilweise ausliefern.
-
-
-
Field Detail
-
RANGE_HEADER
public static final String RANGE_HEADER
- See Also:
- Constant Field Values
-
CONTENT_RANGE_HEADER
public static final String CONTENT_RANGE_HEADER
- See Also:
- Constant Field Values
-
CONTENT_TYPE
public static final String CONTENT_TYPE
- See Also:
- Constant Field Values
-
CONTENT_LENGTH
public static final String CONTENT_LENGTH
- See Also:
- Constant Field Values
-
SC_OK
public static final int SC_OK
- See Also:
- Constant Field Values
-
SC_PARTIAL_CONTENT
public static final int SC_PARTIAL_CONTENT
- See Also:
- Constant Field Values
-
SC_FORBIDDEN
public static final int SC_FORBIDDEN
- See Also:
- Constant Field Values
-
SC_NOT_FOUND
public static final int SC_NOT_FOUND
- See Also:
- Constant Field Values
-
SC_METHOD_NOT_ALLOWED
public static final int SC_METHOD_NOT_ALLOWED
- See Also:
- Constant Field Values
-
SC_UNPROCESSABLE_ENTITY
public static final int SC_UNPROCESSABLE_ENTITY
- See Also:
- Constant Field Values
-
STR_SLASH
public static final String STR_SLASH
- See Also:
- Constant Field Values
-
STR_BLANK
public static final String STR_BLANK
- See Also:
- Constant Field Values
-
STR_DASH
public static final String STR_DASH
- See Also:
- Constant Field Values
-
STR_COMMA
public static final String STR_COMMA
- See Also:
- Constant Field Values
-
STR_DOT
public static final String STR_DOT
- See Also:
- Constant Field Values
-
RANGE_PATTERN
public static final String RANGE_PATTERN
- See Also:
- Constant Field Values
-
WELCOME_FILE
public static final String WELCOME_FILE
- See Also:
- Constant Field Values
-
ATTR_FILE_BASE
public static final String ATTR_FILE_BASE
- See Also:
- Constant Field Values
-
ATTR_WELCOME_FILES
public static final String ATTR_WELCOME_FILES
- See Also:
- Constant Field Values
-
-
Method Detail
-
handle
public void handle(com.sun.net.httpserver.HttpExchange e) throws IOExceptionDie Datei ermitteln, die sich aus dem angefragten URL ergibt, prüfen, ob die Datei existiert und den Inhalt der Datei abhängig davon, ob ein Range-Header vorhanden ist, ganz oder teilweise ausliefern.- Specified by:
handlein interfacecom.sun.net.httpserver.HttpHandler- Parameters:
e- das Objekt mit Methoden zur Untersuchung der Anfrage sowie zum Anfertigen und Senden der Antwort- Throws:
IOException- falls etwas schief geht entsteht dieser Fehler
-
-