public class ToadletContextImpl extends java.lang.Object implements ToadletContext
Constructor and Description |
---|
ToadletContextImpl(java.net.Socket sock,
MultiValueTable<java.lang.String,java.lang.String> headers,
BucketFactory bf,
PageMaker pageMaker,
ToadletContainer container,
UserAlertManager userAlertManager,
BookmarkManager bookmarkManager,
java.net.URI uri,
long uniqueID) |
Modifier and Type | Method and Description |
---|---|
Toadlet |
activeToadlet() |
HTMLNode |
addFormChild(HTMLNode parentNode,
java.lang.String target,
java.lang.String name)
Add a form node to an HTMLNode under construction.
|
boolean |
checkFormPassword(HTTPRequest request)
Check a request for the form password, and send an error to the client if the password is
not valid.
|
boolean |
checkFormPassword(HTTPRequest request,
java.lang.String redirectTo)
Check a request for the form password, and send an error to the client if the password is
not valid.
|
boolean |
checkFullAccess(Toadlet toadlet)
Check a context for whether
ToadletContext.isAllowedFullAccess() is true. |
boolean |
disableProgressPage() |
boolean |
doRobots()
Return a robots.txt excluding all spiders and other non-browser HTTP clients?
|
void |
forceDisconnect()
Force a disconnection after handling this request.
|
UserAlertManager |
getAlertManager()
Get the user alert manager.
|
BookmarkManager |
getBookmarkManager()
Get the bookmark manager.
|
BucketFactory |
getBucketFactory() |
ToadletContainer |
getContainer() |
ReceivedCookie |
getCookie(java.net.URI domain,
java.net.URI path,
java.lang.String name)
Get an existing
Cookie (sent by the client) from the headers. |
java.lang.String |
getFormPassword()
Get the form password required for "dangerous" operations.
|
MultiValueTable<java.lang.String,java.lang.String> |
getHeaders() |
PageMaker |
getPageMaker()
Get the page maker object.
|
FProxyFetchInProgress.REFILTER_POLICY |
getReFilterPolicy()
What to do when we find cached data on the global queue but it's already been
filtered, and we want a filtered copy.
|
java.lang.String |
getUniqueId()
Returns the unique id of this request
|
java.net.URI |
getUri() |
static void |
handle(java.net.Socket sock,
ToadletContainer container,
PageMaker pageMaker,
UserAlertManager userAlertManager,
BookmarkManager bookmarkManager)
Handle an incoming connection.
|
boolean |
hasFormPassword(HTTPRequest request)
Check a request for the form password.
|
boolean |
isAdvancedModeEnabled()
Is the web interface in advanced mode?
|
boolean |
isAllowedFullAccess()
Is this Toadlet allowed full access to the node, including the ability to reconfigure it,
restart it etc?
|
static java.util.Date |
parseHTTPDate(java.lang.String httpDate) |
void |
sendReplyHeaders(int code,
java.lang.String desc,
MultiValueTable<java.lang.String,java.lang.String> mvt,
java.lang.String mimeType,
long length)
Write reply headers for generated content (web interface pages) and redirects etc.
|
void |
sendReplyHeaders(int code,
java.lang.String desc,
MultiValueTable<java.lang.String,java.lang.String> mvt,
java.lang.String mimeType,
long length,
boolean forceDisableJavascript)
Write reply headers for generated content (web interface pages) and redirects etc.
|
void |
sendReplyHeaders(int code,
java.lang.String desc,
MultiValueTable<java.lang.String,java.lang.String> mvt,
java.lang.String mimeType,
long length,
java.util.Date mTime)
Deprecated.
|
void |
sendReplyHeadersFProxy(int replyCode,
java.lang.String replyDescription,
MultiValueTable<java.lang.String,java.lang.String> mvt,
java.lang.String mimeType,
long contentLength)
Write reply headers for content downloaded from Freenet.
|
void |
sendReplyHeadersStatic(int replyCode,
java.lang.String replyDescription,
MultiValueTable<java.lang.String,java.lang.String> mvt,
java.lang.String mimeType,
long contentLength,
java.util.Date mTime)
Write reply headers with a customised modification time for static content.
|
void |
setCookie(Cookie newCookie)
Set a
Cookie , it will be sent with the reply headers to the client. |
void |
writeData(Bucket data)
Write data from a bucket.
|
void |
writeData(byte[] data)
Convenience method that simply calls
ToadletContext.writeData(byte[], int, int) . |
void |
writeData(byte[] data,
int offset,
int length)
Write data.
|
public ToadletContextImpl(java.net.Socket sock, MultiValueTable<java.lang.String,java.lang.String> headers, BucketFactory bf, PageMaker pageMaker, ToadletContainer container, UserAlertManager userAlertManager, BookmarkManager bookmarkManager, java.net.URI uri, long uniqueID) throws java.io.IOException
java.io.IOException
public void sendReplyHeaders(int code, java.lang.String desc, MultiValueTable<java.lang.String,java.lang.String> mvt, java.lang.String mimeType, long length) throws ToadletContextClosedException, java.io.IOException
ToadletContext
sendReplyHeaders
in interface ToadletContext
code
- HTTP code.desc
- HTTP code description.mvt
- Any extra headers. Can be null.mimeType
- The MIME type of the reply.length
- The length of the reply.ToadletContextClosedException
java.io.IOException
public void sendReplyHeaders(int code, java.lang.String desc, MultiValueTable<java.lang.String,java.lang.String> mvt, java.lang.String mimeType, long length, boolean forceDisableJavascript) throws ToadletContextClosedException, java.io.IOException
ToadletContext
sendReplyHeaders
in interface ToadletContext
code
- HTTP code.desc
- HTTP code description.mvt
- Any extra headers. Can be null.mimeType
- The MIME type of the reply.length
- The length of the reply.forceDisableJavascript
- Disable javascript even if it is enabled for the web interface
as a whole.ToadletContextClosedException
java.io.IOException
@Deprecated public void sendReplyHeaders(int code, java.lang.String desc, MultiValueTable<java.lang.String,java.lang.String> mvt, java.lang.String mimeType, long length, java.util.Date mTime) throws ToadletContextClosedException, java.io.IOException
sendReplyHeaders
in interface ToadletContext
ToadletContextClosedException
java.io.IOException
public void sendReplyHeadersStatic(int replyCode, java.lang.String replyDescription, MultiValueTable<java.lang.String,java.lang.String> mvt, java.lang.String mimeType, long contentLength, java.util.Date mTime) throws ToadletContextClosedException, java.io.IOException
ToadletContext
sendReplyHeadersStatic
in interface ToadletContext
replyCode
- HTTP code.replyDescription
- HTTP code description.mvt
- Any extra headers. Can be null.mimeType
- The MIME type of the reply.contentLength
- The length of the reply.mTime
- The modification time of the data being sent.ToadletContextClosedException
java.io.IOException
public void sendReplyHeadersFProxy(int replyCode, java.lang.String replyDescription, MultiValueTable<java.lang.String,java.lang.String> mvt, java.lang.String mimeType, long contentLength) throws ToadletContextClosedException, java.io.IOException
ToadletContext
sendReplyHeadersFProxy
in interface ToadletContext
replyCode
- HTTP code.replyDescription
- HTTP code description.mvt
- Any extra headers. Can be null.mimeType
- The MIME type of the reply.contentLength
- The length of the reply.ToadletContextClosedException
java.io.IOException
public PageMaker getPageMaker()
ToadletContext
getPageMaker
in interface ToadletContext
public java.lang.String getFormPassword()
ToadletContext
getFormPassword
in interface ToadletContext
public boolean checkFormPassword(HTTPRequest request) throws ToadletContextClosedException, java.io.IOException
ToadletContext
checkFormPassword
in interface ToadletContext
request
- The request to check.ToadletContextClosedException
java.io.IOException
public boolean checkFormPassword(HTTPRequest request, java.lang.String redirectTo) throws ToadletContextClosedException, java.io.IOException
ToadletContext
checkFormPassword
in interface ToadletContext
request
- The request to check.redirectTo
- The location to redirect to if the password is not set.ToadletContextClosedException
java.io.IOException
public boolean checkFullAccess(Toadlet toadlet) throws ToadletContextClosedException, java.io.IOException
ToadletContext
ToadletContext.isAllowedFullAccess()
is true.
If it is false, an error page is sent to the client, and false is returned.
You can then abort processing of the request.checkFullAccess
in interface ToadletContext
ToadletContext.isAllowedFullAccess()
.ToadletContextClosedException
- See Toadlet.sendUnauthorizedPage(ToadletContext)
java.io.IOException
- See Toadlet.sendUnauthorizedPage(ToadletContext)
ToadletContext.checkFullAccess(Toadlet)
public boolean hasFormPassword(HTTPRequest request) throws java.io.IOException
ToadletContext
hasFormPassword
in interface ToadletContext
java.io.IOException
public UserAlertManager getAlertManager()
ToadletContext
getAlertManager
in interface ToadletContext
public BookmarkManager getBookmarkManager()
ToadletContext
getBookmarkManager
in interface ToadletContext
public MultiValueTable<java.lang.String,java.lang.String> getHeaders()
getHeaders
in interface ToadletContext
public ReceivedCookie getCookie(java.net.URI domain, java.net.URI path, java.lang.String name) throws java.text.ParseException
ToadletContext
Cookie
(sent by the client) from the headers.getCookie
in interface ToadletContext
java.text.ParseException
public void setCookie(Cookie newCookie)
ToadletContext
Cookie
, it will be sent with the reply headers to the client.setCookie
in interface ToadletContext
public static java.util.Date parseHTTPDate(java.lang.String httpDate) throws java.text.ParseException
java.text.ParseException
public static void handle(java.net.Socket sock, ToadletContainer container, PageMaker pageMaker, UserAlertManager userAlertManager, BookmarkManager bookmarkManager)
public Toadlet activeToadlet()
activeToadlet
in interface ToadletContext
public void writeData(byte[] data, int offset, int length) throws ToadletContextClosedException, java.io.IOException
ToadletContext
writeData
in interface ToadletContext
ToadletContextClosedException
java.io.IOException
public void writeData(byte[] data) throws ToadletContextClosedException, java.io.IOException
ToadletContext
ToadletContext.writeData(byte[], int, int)
.writeData
in interface ToadletContext
data
- The data to writeToadletContextClosedException
- if the context has already been closedjava.io.IOException
- if an I/O error occurspublic void writeData(Bucket data) throws ToadletContextClosedException, java.io.IOException
ToadletContext
writeData
in interface ToadletContext
data
- The Bucket which contains the reply data. This
function assumes ownership of the Bucket, calling free()
on it when done. If this behavior is undesired, callers
can wrap their Bucket in a NoFreeBucket.ToadletContextClosedException
java.io.IOException
NoFreeBucket
public BucketFactory getBucketFactory()
getBucketFactory
in interface ToadletContext
public HTMLNode addFormChild(HTMLNode parentNode, java.lang.String target, java.lang.String name)
ToadletContext
addFormChild
in interface ToadletContext
parentNode
- The parent HTMLNode.target
- Where the form should be POSTed to.name
- HTML name for the form for stylesheet/script access. Will be added as both id and name.public boolean isAllowedFullAccess()
ToadletContext
isAllowedFullAccess
in interface ToadletContext
public boolean isAdvancedModeEnabled()
ToadletContext
isAdvancedModeEnabled
in interface ToadletContext
public boolean doRobots()
ToadletContext
doRobots
in interface ToadletContext
public void forceDisconnect()
ToadletContext
forceDisconnect
in interface ToadletContext
public ToadletContainer getContainer()
getContainer
in interface ToadletContext
public boolean disableProgressPage()
disableProgressPage
in interface ToadletContext
public java.lang.String getUniqueId()
ToadletContext
getUniqueId
in interface ToadletContext
public java.net.URI getUri()
getUri
in interface ToadletContext
public FProxyFetchInProgress.REFILTER_POLICY getReFilterPolicy()
ToadletContext
getReFilterPolicy
in interface ToadletContext