public class HttpResource extends Object
Modifier and Type | Class and Description |
---|---|
static class |
HttpResource.HttpDataParams
Small parameter object that is sent to getData method, and all
methods thereafter.
|
Modifier and Type | Field and Description |
---|---|
String |
extension
The extension of the resource.
|
String |
fileName
The file name of the resource (includes the 'htdocs' path).
|
boolean |
isFromRoot
Is resource name is root directory address or relative the document root.
|
String |
name
The name of the resource.
|
HttpWebServer |
webServer
The web server.
|
Constructor and Description |
---|
HttpResource(HttpWebServer webServer,
String fileName,
String name,
String extension)
Creates a new file resource without loading it.
|
HttpResource(HttpWebServer webServer,
String fileName,
String name,
String extension,
byte[] data,
long lastModified)
Creates a new file resource with file name, data and last modified, typically used for
client Jar files.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getData(HttpSession httpSession,
HttpResource.HttpDataParams dParams)
Get the data that is transformed through parsing and modification of
the resource if the resource is an HTML document.
|
long |
getFileSize()
Gets the file size, typically used for large binary resources.
|
int |
getHitCount()
Gets the hit count of this resource.
|
long |
getLastModified()
Gets the variable that represents the time when this resource was last modified.
|
HttpResource.HttpDataParams |
getParamObj(boolean isInclude)
Get parameter object to getData method.
|
boolean |
hasDynamicData(HttpSession httpSession)
Checks if this resource could return different content for each call to getData
when the last modified time has not been changed.
|
void |
increaseHitCount()
Increases the hit count of this resource.
|
boolean |
isHandleSet()
Check if it's handle is set, i.e.
|
boolean |
isUncached()
Checks if this resource is of "large" binary (byte array) type that exceeds
the block size for sending data to the client.
|
long |
load(HttpResourceParameters httpParams)
Loads or reloads a resource if required.
|
boolean |
reload()
Reloads a the resource if required.
|
void |
sendRawDataInBlocks(OutputStream out)
Sends the raw data in block size.
|
public final HttpWebServer webServer
public final String name
public final String fileName
public final String extension
public boolean isFromRoot
public HttpResource(HttpWebServer webServer, String fileName, String name, String extension)
load
method.public HttpResource(HttpWebServer webServer, String fileName, String name, String extension, byte[] data, long lastModified)
This constructor is intended to be used internally and should not be used.
public final void increaseHitCount()
public final int getHitCount()
public boolean isHandleSet()
public final long load(HttpResourceParameters httpParams) throws IOException, FileNotFoundException
If a resource fails to load because it's not found, it will throw an error. The size it returns is zero if the resource is already loaded (previously or by another thread at the same time).
If the resource is reloaded because it has been changed on the file system since last load, the size returned is the difference between the first load and the new one.
IOException
- if the loading of the resource fails even when it exists.FileNotFoundException
- if the loading of the resource cannot be found.public boolean reload()
If the document is not loaded, nothing will happen.
No failures will occur, because (e.g.) if the file is not found anymore the first content will be used.
This is typically done for application or error documents.
public final long getFileSize()
public byte[] getData(HttpSession httpSession, HttpResource.HttpDataParams dParams)
For the HttpResource class, the raw data is returned.
public HttpResource.HttpDataParams getParamObj(boolean isInclude)
public final boolean isUncached()
Note: This method cannot be overridden by an extending class.
public final void sendRawDataInBlocks(OutputStream out) throws IOException
Note: This method cannot be overridden by an extending class.
IOException
- for errors.public final long getLastModified()
public boolean hasDynamicData(HttpSession httpSession)
httpSession
- The session instance.Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.