public class YaCyDefaultServlet
extends HttpServlet
acceptRanges If true, range requests and responses are supported dirAllowed If true, directory listings are returned if no welcome file is found. Else 403 Forbidden. welcomeFile name of the welcome file (default is "index.html", "welcome.html") resourceBase Set to replace the context resource base pathInfoOnly If true, only the path info will be applied to the resourceBase
Modifier and Type | Class and Description |
---|---|
private class |
YaCyDefaultServlet.CallableReader |
private class |
YaCyDefaultServlet.GZIPRequestStream |
private class |
YaCyDefaultServlet.GZIPRequestWrapper
wraps request to uncompress gzip'ed input stream
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
_acceptRanges |
protected boolean |
_dirAllowed |
protected java.io.File |
_htDocsPath |
protected java.io.File |
_htLocalePath |
protected MimeTypes |
_mimeTypes |
protected boolean |
_pathInfoOnly |
protected Resource |
_resourceBase |
protected ServletContext |
_servletContext |
protected java.lang.String[] |
_welcomes |
protected static FileItemFactory |
DISK_FILE_ITEM_FACTORY |
protected static serverClassLoader |
provider |
private static long |
serialVersionUID |
protected static int |
SIZE_FILE_THRESHOLD |
protected java.util.concurrent.ConcurrentHashMap<java.io.File,java.lang.ref.SoftReference<java.lang.reflect.Method>> |
templateMethodCache |
private static TimeLimiter |
timeLimiter |
protected static java.io.File |
TMPDIR |
Constructor and Description |
---|
YaCyDefaultServlet() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
appendPath(java.lang.String proplist,
java.lang.String path) |
static RequestHeader |
convertHeaderFromJetty(HttpServletRequest request)
Convert ServletRequest header to YaCy RequestHeader
|
protected void |
doGet(HttpServletRequest request,
HttpServletResponse response) |
protected void |
doOptions(HttpServletRequest req,
HttpServletResponse resp) |
protected void |
doPost(HttpServletRequest request,
HttpServletResponse response) |
protected void |
doTrace(HttpServletRequest req,
HttpServletResponse resp) |
protected RequestHeader |
generateLegacyRequestHeader(HttpServletRequest request,
java.lang.String target,
java.lang.String targetExt) |
protected boolean |
getInitBoolean(java.lang.String name,
boolean dft) |
java.io.File |
getLocalizedFile(java.lang.String path,
java.lang.String localeSelection)
Returns a path to the localized or default file according to the
parameter localeSelection
|
Resource |
getResource(java.lang.String pathInContext)
get Resource to serve.
|
protected java.lang.String |
getWelcomeFile(java.lang.String pathInContext)
Finds a matching welcome file for the supplied path.
|
protected void |
handleTemplate(java.lang.String target,
HttpServletRequest request,
HttpServletResponse response) |
protected boolean |
hasDefinedRange(java.util.Enumeration<java.lang.String> reqRanges) |
void |
init() |
protected java.lang.Object |
invokeServlet(java.io.File targetClass,
RequestHeader request,
serverObjects args) |
protected void |
parseMultipart(HttpServletRequest request,
serverObjects args)
TODO: add same functionality & checks as in HTTPDemon.parseMultipart
parse multi-part form data for formfields, see also original
implementation in HTTPDemon.parseMultipart
For file data the parameter for the formfield contains the filename and a
additional parameter with appendix [fieldname]$file conteins the upload content
(e.g.
|
protected void |
parseSSI(byte[] in,
HttpServletRequest request,
HttpServletResponse response)
parse SSI line and include resource ()
|
protected boolean |
passConditionalHeaders(HttpServletRequest request,
HttpServletResponse response,
Resource resource) |
protected java.io.File |
rewriteClassFile(java.io.File template) |
protected java.lang.reflect.Method |
rewriteMethod(java.io.File classFile) |
protected void |
sendData(HttpServletRequest request,
HttpServletResponse response,
boolean include,
Resource resource,
java.util.Enumeration<java.lang.String> reqRanges)
send static content
|
protected void |
sendDirectory(HttpServletRequest request,
HttpServletResponse response,
Resource resource,
java.lang.String pathInContext) |
protected void |
writeHeaders(HttpServletResponse response,
Resource resource,
long count) |
private void |
writeInputStream(HttpServletResponse response,
java.lang.String targetExt,
java.io.InputStream inStream)
Write input stream content to response and close input stream.
|
private static final long serialVersionUID
protected ServletContext _servletContext
protected boolean _acceptRanges
protected boolean _dirAllowed
protected boolean _pathInfoOnly
protected Resource _resourceBase
protected MimeTypes _mimeTypes
protected java.lang.String[] _welcomes
protected java.io.File _htLocalePath
protected java.io.File _htDocsPath
protected static final serverClassLoader provider
protected java.util.concurrent.ConcurrentHashMap<java.io.File,java.lang.ref.SoftReference<java.lang.reflect.Method>> templateMethodCache
protected static final java.io.File TMPDIR
protected static final int SIZE_FILE_THRESHOLD
protected static final FileItemFactory DISK_FILE_ITEM_FACTORY
private static final TimeLimiter timeLimiter
public void init() throws UnavailableException
UnavailableException
protected boolean getInitBoolean(java.lang.String name, boolean dft)
public Resource getResource(java.lang.String pathInContext)
pathInContext
- The path to find a resource for.protected boolean hasDefinedRange(java.util.Enumeration<java.lang.String> reqRanges)
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException
ServletException
java.io.IOException
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException
ServletException
java.io.IOException
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
ServletException
java.io.IOException
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
ServletException
java.io.IOException
protected java.lang.String getWelcomeFile(java.lang.String pathInContext)
pathInContext
- path in contextprotected boolean passConditionalHeaders(HttpServletRequest request, HttpServletResponse response, Resource resource) throws java.io.IOException
java.io.IOException
protected void sendDirectory(HttpServletRequest request, HttpServletResponse response, Resource resource, java.lang.String pathInContext) throws java.io.IOException
java.io.IOException
protected void sendData(HttpServletRequest request, HttpServletResponse response, boolean include, Resource resource, java.util.Enumeration<java.lang.String> reqRanges) throws java.io.IOException
request
- response
- include
- is a include file (send without changing/adding headers)resource
- the static contentreqRanges
- java.io.IOException
protected void writeHeaders(HttpServletResponse response, Resource resource, long count)
protected java.lang.Object invokeServlet(java.io.File targetClass, RequestHeader request, serverObjects args) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static RequestHeader convertHeaderFromJetty(HttpServletRequest request)
request
- ServletRequestprotected RequestHeader generateLegacyRequestHeader(HttpServletRequest request, java.lang.String target, java.lang.String targetExt)
public java.io.File getLocalizedFile(java.lang.String path, java.lang.String localeSelection) throws java.io.IOException
path
- relative from htrootlocaleSelection
- language of localized file; locale.language from
switchboard is used if localeSelection.equals("")java.io.IOException
protected java.io.File rewriteClassFile(java.io.File template)
protected java.lang.reflect.Method rewriteMethod(java.io.File classFile) throws java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
protected void handleTemplate(java.lang.String target, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException
java.io.IOException
ServletException
private void writeInputStream(HttpServletResponse response, java.lang.String targetExt, java.io.InputStream inStream) throws java.io.IOException
response
- servlet response. Must not be null.targetExt
- response file formattmp
- java.io.IOException
- when a read/write error occured.private static java.lang.String appendPath(java.lang.String proplist, java.lang.String path)
protected void parseSSI(byte[] in, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException
java.io.IOException
ServletException
protected void parseMultipart(HttpServletRequest request, serverObjects args) throws java.io.IOException
request
- args
- found fields/values are added to the mapjava.io.IOException