org.littleshoot.proxy.impl
Class ProxyUtils

java.lang.Object
  extended by org.littleshoot.proxy.impl.ProxyUtils

public class ProxyUtils
extends Object

Utilities for the proxy.


Method Summary
static void addVia(io.netty.handler.codec.http.HttpMessage msg)
          Adds the Via header to specify that the message has passed through the proxy.
static io.netty.handler.codec.http.HttpResponse copyMutableResponseFields(io.netty.handler.codec.http.HttpResponse original)
          Make a copy of the response including all mutable fields.
static boolean extractBooleanDefaultFalse(Properties props, String key)
           
static boolean extractBooleanDefaultTrue(Properties props, String key)
           
static int extractInt(Properties props, String key)
           
static int extractInt(Properties props, String key, int defaultValue)
           
static String formatDate(Date date)
          Formats the given date according to the RFC 1123 pattern.
static String formatDate(Date date, String pattern)
          Formats the given date according to the specified pattern.
static String httpDate()
          Creates a Date formatted for HTTP headers for the current time.
static boolean isChunked(io.netty.handler.codec.http.HttpObject httpObject)
          If an HttpObject is not the last chunk, then that means there are other chunks that will follow.
static boolean isCONNECT(io.netty.handler.codec.http.HttpObject httpObject)
           
static boolean isFalse(String val)
          Returns true if the specified string is either "false" or "off" ignoring case.
static boolean isLastChunk(io.netty.handler.codec.http.HttpObject httpObject)
          If an HttpObject implements the market interface LastHttpContent, it represents the last chunk of a transfer.
static boolean isTrue(String val)
          Returns true if the specified string is either "true" or "on" ignoring case.
static String parseHostAndPort(io.netty.handler.codec.http.HttpRequest httpRequest)
          Parses the host and port an HTTP request is being sent to.
static String parseHostAndPort(String uri)
          Parses the host and port an HTTP request is being sent to.
static String stripHost(String uri)
          Strips the host from a URI string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

stripHost

public static String stripHost(String uri)
Strips the host from a URI string. This will turn "http://host.com/path" into "/path".

Parameters:
uri - The URI to transform.
Returns:
A string with the URI stripped.

formatDate

public static String formatDate(Date date)
Formats the given date according to the RFC 1123 pattern.

Parameters:
date - The date to format.
Returns:
An RFC 1123 formatted date string.
See Also:
PATTERN_RFC1123

formatDate

public static String formatDate(Date date,
                                String pattern)
Formats the given date according to the specified pattern. The pattern must conform to that used by the simple date format class.

Parameters:
date - The date to format.
pattern - The pattern to use for formatting the date.
Returns:
A formatted date string.
Throws:
IllegalArgumentException - If the given date pattern is invalid.
See Also:
SimpleDateFormat

httpDate

public static String httpDate()
Creates a Date formatted for HTTP headers for the current time.

Returns:
The formatted HTTP date.

isLastChunk

public static boolean isLastChunk(io.netty.handler.codec.http.HttpObject httpObject)
If an HttpObject implements the market interface LastHttpContent, it represents the last chunk of a transfer.

Parameters:
httpObject -
Returns:
See Also:
LastHttpContent

isChunked

public static boolean isChunked(io.netty.handler.codec.http.HttpObject httpObject)
If an HttpObject is not the last chunk, then that means there are other chunks that will follow.

Parameters:
httpObject -
Returns:
See Also:
FullHttpMessage

parseHostAndPort

public static String parseHostAndPort(io.netty.handler.codec.http.HttpRequest httpRequest)
Parses the host and port an HTTP request is being sent to.

Parameters:
httpRequest - The request.
Returns:
The host and port string.

parseHostAndPort

public static String parseHostAndPort(String uri)
Parses the host and port an HTTP request is being sent to.

Parameters:
uri - The URI.
Returns:
The host and port string.

copyMutableResponseFields

public static io.netty.handler.codec.http.HttpResponse copyMutableResponseFields(io.netty.handler.codec.http.HttpResponse original)
Make a copy of the response including all mutable fields.

Parameters:
original - The original response to copy from.
Returns:
The copy with all mutable fields from the original.

addVia

public static void addVia(io.netty.handler.codec.http.HttpMessage msg)
Adds the Via header to specify that the message has passed through the proxy.

Parameters:
msg - The HTTP message.

isTrue

public static boolean isTrue(String val)
Returns true if the specified string is either "true" or "on" ignoring case.

Parameters:
val - The string in question.
Returns:
true if the specified string is either "true" or "on" ignoring case, otherwise false.

isFalse

public static boolean isFalse(String val)
Returns true if the specified string is either "false" or "off" ignoring case.

Parameters:
val - The string in question.
Returns:
true if the specified string is either "false" or "off" ignoring case, otherwise false.

extractBooleanDefaultFalse

public static boolean extractBooleanDefaultFalse(Properties props,
                                                 String key)

extractBooleanDefaultTrue

public static boolean extractBooleanDefaultTrue(Properties props,
                                                String key)

extractInt

public static int extractInt(Properties props,
                             String key)

extractInt

public static int extractInt(Properties props,
                             String key,
                             int defaultValue)

isCONNECT

public static boolean isCONNECT(io.netty.handler.codec.http.HttpObject httpObject)


Copyright © 2009-2014 LittleShoot. All Rights Reserved.