|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectorg.xlightweb.HttpUtils
public final class HttpUtils
A HTTP utility class
| Method Summary | |
|---|---|
static void |
clearCaches()
clears the internal caches This is a xSocket internal method and subject to change |
static BlockingBodyDataSource |
compress(BlockingBodyDataSource dataSource)
Deprecated. |
static BodyDataSource |
compress(BodyDataSource dataSource)
compresses a body (using the GZIP compression) |
static byte[] |
compress(byte[] data)
compresses a byte array (using the GZIP compression) |
static byte[] |
computeRFC2104HMAC(byte[] data,
byte[] key)
computes a HMAC-SHA1 Signature |
static IHttpRequest |
copy(IHttpRequest request)
Copies a request. |
static IHttpResponse |
copy(IHttpResponse response)
Copies a response. |
static byte[] |
decodeBase64(byte[] bytes)
decodes the given byte array |
static BlockingBodyDataSource |
decompress(BlockingBodyDataSource dataSource)
Deprecated. |
static BodyDataSource |
decompress(BodyDataSource dataSource)
decompresses a body (using the GZIP decompression) |
static byte[] |
decompress(byte[] compressedData)
decompresses a byte array (using the GZIP decompression) |
static byte[] |
encodeBase64(byte[] bytes)
encodes the given byte array |
static void |
establishTcpTunnel(IHttpConnection httpConnection,
String target)
establishs a tcp tunnel |
static void |
establishTcpTunnel(IHttpConnection httpConnection,
String targetHost,
int targetPort)
establishs a tcp tunnel |
static String |
getImplementationDate()
get the implementation date |
static String |
getImplementationVersion()
get the implementation version |
static Map<String,String> |
getMimeTypeMapping()
get the mime type file to extension map |
static String |
getReason(int statusCode)
returns the reason text |
static boolean |
hasContentType(IHeader header,
String contentType)
returns if the content type of the header match with the given one |
static boolean |
isAcceptEncdoingGzip(IHttpRequestHeader requestHeader)
|
static boolean |
isAfter(String dateString,
long referenceTime)
|
static boolean |
isBodylessStatus(int status)
returns true, if the response is bodyless per definition |
static boolean |
isCompressableMimeType(String mimeType)
|
static boolean |
isConnectHandlerWarningIsSuppressed()
returns if the connect handler warning is suppressed This is a xSocket internal method and subject to change |
static boolean |
isContainExpect100ContinueHeader(IHttpMessageHeader header)
returns true if the header contains a Expect: 100-continue header |
static boolean |
isContainsExpect100ContinueHeader(IHttpRequest request)
|
static boolean |
isMethodMultithreaded(Class clazz,
String methodname,
boolean dflt,
Class... paramClass)
returns if the handler method is multi threaded This is a xSocket internal method and subject to change |
static boolean |
isShowDetailedError()
returns true, if detailed error messages should been shown. |
static Date |
parseDateTimeString(String dateTimeString)
|
static String |
parseEncoding(String contentType)
parse extracts the encoding parameter of the content type |
static String |
parseEncodingWithDefault(String contentType,
String dflt)
parse extracts the encoding parameter of the content type |
static Date |
parseHttpDateString(String dateString)
|
static long |
parseLong(String longString,
long dflt)
This is a xSocket internal method and subject to change |
static String |
removeMediaTypeParameters(String mediaType)
returns the given media type string without parameters |
static String |
removeSurroundingSlashes(String path)
|
static String |
resolveContentTypeByFileExtension(File file)
returns the content type based on the file extension |
static void |
setExpireHeaders(IHttpResponseHeader header,
int expireSec)
set the caching expires headers of a response |
static void |
setLastModifiedHeader(IHttpResponseHeader header,
long timeMillis)
set a last modified header of the response |
static String |
toDateTimeString(Date date)
|
static IOException |
toIOException(Throwable t)
wraps a exception with an io exception |
static String |
toRFC1123DateString(Date date)
|
static int |
validateSufficientDatasizeByIntLengthField(NonBlockingBodyDataSource stream)
validate, based on a leading int length field. |
static int |
validateSufficientDatasizeByIntLengthField(NonBlockingBodyDataSource stream,
boolean removeLengthField)
validate, based on a leading int length field, that enough data (getNumberOfAvailableBytes() >= length) is available. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isShowDetailedError()
IHttpExchange.SHOW_DETAILED_ERROR_KEY
public static void clearCaches()
public static String getReason(int statusCode)
statusCode - the status code
public static byte[] encodeBase64(byte[] bytes)
throws IOException
bytes - byte array to encode
IOException - if an exception occurs
public static byte[] decodeBase64(byte[] bytes)
throws IOException
bytes - byte array to decode
IOException - if an exception occurs
public static int validateSufficientDatasizeByIntLengthField(NonBlockingBodyDataSource stream)
throws IOException,
BufferUnderflowException
connection - the connection
IOException - if an exception occurs
BufferUnderflowException - if not enough data is available
public static int validateSufficientDatasizeByIntLengthField(NonBlockingBodyDataSource stream,
boolean removeLengthField)
throws IOException,
BufferUnderflowException
connection - the connectionremoveLengthField - true, if length field should be removed
IOException - if an exception occurs
BufferUnderflowException - if not enough data is availablepublic static Map<String,String> getMimeTypeMapping()
public static boolean hasContentType(IHeader header,
String contentType)
header - the headercontentType - the content type
public static boolean isBodylessStatus(int status)
header - the status
public static boolean isAfter(String dateString,
long referenceTime)
public static String removeMediaTypeParameters(String mediaType)
mediaType - the media type string
public static String parseEncoding(String contentType)
contentType - the content type
public static String parseEncodingWithDefault(String contentType,
String dflt)
contentType - the content type
public static IHttpRequest copy(IHttpRequest request)
throws IOException
request - the request
IOException - if an exception occurs
public static IHttpResponse copy(IHttpResponse response)
throws IOException
response - the response
IOException - if an exception occurspublic static IOException toIOException(Throwable t)
t - the exception
public static BlockingBodyDataSource compress(BlockingBodyDataSource dataSource)
throws IOException
IOException
public static BodyDataSource compress(BodyDataSource dataSource)
throws IOException
dataSource - the body to compress
IOException - if an excption occurs
public static byte[] compress(byte[] data)
throws IOException
dataSource - the byte array to compress
IOException - if an excption occurs
public static BlockingBodyDataSource decompress(BlockingBodyDataSource dataSource)
throws IOException
IOException
public static BodyDataSource decompress(BodyDataSource dataSource)
throws IOException
dataSource - the body to decompress
IOException - if an excption occurs
public static byte[] decompress(byte[] compressedData)
throws IOException
compressedData -
IOExceptionpublic static boolean isCompressableMimeType(String mimeType)
public static void setExpireHeaders(IHttpResponseHeader header,
int expireSec)
header - the headerexpireSec - the expire time or 0 to set no-cache headers
public static void setLastModifiedHeader(IHttpResponseHeader header,
long timeMillis)
header - the headertimeMillis - the last modified time in millispublic static String toDateTimeString(Date date)
public static Date parseDateTimeString(String dateTimeString)
throws ParseException
ParseException
public static byte[] computeRFC2104HMAC(byte[] data,
byte[] key)
throws IOException
data - the datakey - the key
IOException - if an error occurspublic static String toRFC1123DateString(Date date)
public static Date parseHttpDateString(String dateString)
public static boolean isContainExpect100ContinueHeader(IHttpMessageHeader header)
header - the request header
public static boolean isContainsExpect100ContinueHeader(IHttpRequest request)
public static String removeSurroundingSlashes(String path)
public static final String resolveContentTypeByFileExtension(File file)
file - the filepublic static String getImplementationVersion()
public static long parseLong(String longString,
long dflt)
public static String getImplementationDate()
public static boolean isMethodMultithreaded(Class clazz,
String methodname,
boolean dflt,
Class... paramClass)
clazz - the handler classmethodname - the method namedflt - the default valueparamClass - the method parameter classes
public static boolean isConnectHandlerWarningIsSuppressed()
public static boolean isAcceptEncdoingGzip(IHttpRequestHeader requestHeader)
public static void establishTcpTunnel(IHttpConnection httpConnection,
String target)
throws IOException
httpConnection - the http connectiontarget - the target address (e.g. www.gmx.com, www.gmx.com:443)
IOException - if an exception occurs
public static void establishTcpTunnel(IHttpConnection httpConnection,
String targetHost,
int targetPort)
throws IOException
httpConnection - the http connectiontargetHost - the target hosttargetPort - the target port
IOException - if an exception occurs
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||