public class ScriptHelperImpl extends Object implements ScriptHelper, Closeable
ScriptHelper| Modifier and Type | Field and Description |
|---|---|
protected static HashMap<String,sun.net.www.MimeEntry> |
MimeExtensionsMap |
protected static HashMap<String,sun.net.www.MimeEntry> |
MimeTypeMap |
ScriptLogger| Constructor and Description |
|---|
ScriptHelperImpl(org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context,
org.apache.commons.pool2.ObjectPool<ByteBuffer> bufferPool)
Primary constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected static void |
AddMimeEntry(String type,
String extensions)
Add a mime entry to the table.
|
void |
close()
Close out any resources that are owned by this object.
|
ByteBuffer |
createBuffer()
Returns a
ByteBuffer that will be automatically cleaned up once the transaction completes. |
sun.net.www.MimeEntry |
findMimeEntryByExt(String ext)
Locate a
sun.net.www.MimeEntry by the file extension that has been associated with it. |
sun.net.www.MimeEntry |
findMimeEntryByType(String mimeType)
Locate a
sun.net.www.MimeEntry by it's MIMEType |
String |
formatDate(long millisecondsSinceEpoch)
Format millisecond based date into a GMT string compatible with HTTP headers protocol.
|
String[] |
getAcceptableLocales()
Return the language Locales accepted by the requesting client in order of preference (best to least).
|
String |
getCharacterEncoding()
Returns the charset of the Content-Type header
|
static String |
GetCharsetFromContentType(String contentType)
Parse the character encoding from the specified content type header.
|
String |
getHOSTName()
Returns the host name as seen by the calling client.
|
int |
getHOSTPort()
Returns the host port as seen by the calling client.
|
DateFormat |
getHTTPDateFormater()
Get a new date formatter compatible with HTTP headers protocol.
|
InetAddress |
getLocalAddress()
Return the underlying local
InetAddress for this request / response transaction |
int |
getLocalPort()
Return the underlying local socket port for this request / response transaction
|
InetAddress |
getRemoteAddress()
Return the underlying remote
InetAddress for this request / response transaction |
int |
getRemotePort()
Return the underlying remote socket port for this request / response transaction
|
String |
getScheme()
Returns http or https scheme of this transaction
|
static boolean |
HasScheme(String uri)
Determine if a URI string has a
scheme component. |
String |
makeAbsoluteUrl(String location)
Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL.
|
static String |
NormalizeURL(String taintedURL)
Normalization code courtesy of 'Mike Houston' http://stackoverflow.com/questions/2993649/how-to-normalize-a-url-in-java
|
static String |
PercentEncodeRfc3986(String string)
Percent-encode values according the RFC 3986.
|
public ScriptHelperImpl(org.apache.http.HttpRequest request,
org.apache.http.protocol.HttpContext context,
org.apache.commons.pool2.ObjectPool<ByteBuffer> bufferPool)
request - Request as it was received from the clientcontext - The context of this http transactionbufferPool - A pool from which ByteBuffers can be obtained.public void close()
close in interface Closeableclose in interface AutoCloseablepublic ByteBuffer createBuffer()
ScriptHelperByteBuffer that will be automatically cleaned up once the transaction completes.createBuffer in interface ScriptHelperpublic String getScheme()
ScriptHelpergetScheme in interface ScriptHelperpublic String makeAbsoluteUrl(String location)
ScriptHelpermakeAbsoluteUrl in interface ScriptHelperlocation - URL to be (possibly) converted and then returnedpublic String[] getAcceptableLocales()
ScriptHelpergetAcceptableLocales in interface ScriptHelperpublic sun.net.www.MimeEntry findMimeEntryByType(String mimeType)
ScriptHelpersun.net.www.MimeEntry by it's MIMETypefindMimeEntryByType in interface ScriptHelperpublic sun.net.www.MimeEntry findMimeEntryByExt(String ext)
ScriptHelpersun.net.www.MimeEntry by the file extension that has been associated with it.findMimeEntryByExt in interface ScriptHelperprotected static void AddMimeEntry(String type, String extensions)
type - Mime formatted typeextensions - Comma separated list of dot (.) prefixed extensions.RuntimeException - If the extensions string is not properly formatted (see parameters).public InetAddress getLocalAddress()
ScriptHelperInetAddress for this request / response transactiongetLocalAddress in interface ScriptHelperpublic int getLocalPort()
ScriptHelpergetLocalPort in interface ScriptHelperpublic InetAddress getRemoteAddress()
ScriptHelperInetAddress for this request / response transactiongetRemoteAddress in interface ScriptHelperpublic int getRemotePort()
ScriptHelpergetRemotePort in interface ScriptHelperpublic String getHOSTName()
ScriptHelpergetHOSTName in interface ScriptHelperpublic int getHOSTPort()
ScriptHelpergetHOSTPort in interface ScriptHelperpublic String getCharacterEncoding()
ScriptHelpergetCharacterEncoding in interface ScriptHelperpublic DateFormat getHTTPDateFormater()
ScriptHelpergetHTTPDateFormater in interface ScriptHelperpublic String formatDate(long millisecondsSinceEpoch)
ScriptHelperformatDate in interface ScriptHelpermillisecondsSinceEpoch - URL to be (possibly) converted and then returnedpublic static boolean HasScheme(String uri)
scheme component.public static String PercentEncodeRfc3986(String string)
string - Decoded string.public static String NormalizeURL(String taintedURL) throws MalformedURLException
MalformedURLExceptionpublic static String GetCharsetFromContentType(String contentType)
null is returned.contentType - a content type headerCopyright © 2015–2024 Frank Stock. All rights reserved.