Class WebServerFilter
java.lang.Object
org.glassfish.grizzly.filterchain.BaseFilter
org.glassfish.grizzly.samples.http.download.WebServerFilter
- All Implemented Interfaces:
org.glassfish.grizzly.filterchain.Filter
public class WebServerFilter
extends org.glassfish.grizzly.filterchain.BaseFilter
Simple Web server implementation, which locates requested resources in a
local filesystem and transfers it asynchronously to a client.
- Author:
- Alexey Stashok
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.glassfish.grizzly.filterchain.NextActionhandleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) The method is called once we have received someHttpContent.Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, handleAccept, handleClose, handleConnect, handleEvent, handleWrite, onAdded, onFilterChainChanged, onRemoved, toString
-
Constructor Details
-
WebServerFilter
Construct a WebServer- Parameters:
rootFolder- Root folder in a local filesystem, where server will look for resources
-
-
Method Details
-
handleRead
public org.glassfish.grizzly.filterchain.NextAction handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException The method is called once we have received someHttpContent. Filter getsHttpContent, which represents a part or complete HTTP request. If it's just a chunk of a complete HTTP request - filter checks whether it's the last chunk, if not - swallows content and returns. If incomingHttpContentrepresents complete HTTP request or it is the last HTTP request - it initiates file download and sends the file asynchronously to the client.- Specified by:
handleReadin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleReadin classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- Request processing context- Returns:
NextAction- Throws:
IOException
-