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 ByteBuffer
s can be obtained.public void close()
close
in interface Closeable
close
in interface AutoCloseable
public ByteBuffer createBuffer()
ScriptHelper
ByteBuffer
that will be automatically cleaned up once the transaction completes.createBuffer
in interface ScriptHelper
public String getScheme()
ScriptHelper
getScheme
in interface ScriptHelper
public String makeAbsoluteUrl(String location)
ScriptHelper
makeAbsoluteUrl
in interface ScriptHelper
location
- URL to be (possibly) converted and then returnedpublic String[] getAcceptableLocales()
ScriptHelper
getAcceptableLocales
in interface ScriptHelper
public sun.net.www.MimeEntry findMimeEntryByType(String mimeType)
ScriptHelper
sun.net.www.MimeEntry
by it's MIMETypefindMimeEntryByType
in interface ScriptHelper
public sun.net.www.MimeEntry findMimeEntryByExt(String ext)
ScriptHelper
sun.net.www.MimeEntry
by the file extension that has been associated with it.findMimeEntryByExt
in interface ScriptHelper
protected 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()
ScriptHelper
InetAddress
for this request / response transactiongetLocalAddress
in interface ScriptHelper
public int getLocalPort()
ScriptHelper
getLocalPort
in interface ScriptHelper
public InetAddress getRemoteAddress()
ScriptHelper
InetAddress
for this request / response transactiongetRemoteAddress
in interface ScriptHelper
public int getRemotePort()
ScriptHelper
getRemotePort
in interface ScriptHelper
public String getHOSTName()
ScriptHelper
getHOSTName
in interface ScriptHelper
public int getHOSTPort()
ScriptHelper
getHOSTPort
in interface ScriptHelper
public String getCharacterEncoding()
ScriptHelper
getCharacterEncoding
in interface ScriptHelper
public DateFormat getHTTPDateFormater()
ScriptHelper
getHTTPDateFormater
in interface ScriptHelper
public String formatDate(long millisecondsSinceEpoch)
ScriptHelper
formatDate
in interface ScriptHelper
millisecondsSinceEpoch
- 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
MalformedURLException
public static String GetCharsetFromContentType(String contentType)
null
is returned.contentType
- a content type headerCopyright © 2015–2024 Frank Stock. All rights reserved.