public class ProxyUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CONNECT_OK_HEADERS
Constant for the headers for an OK response to an HTTP connect request.
|
static org.jboss.netty.channel.ChannelFutureListener |
NO_OP_LISTENER
Utility class for a no-op
ChannelFutureListener. |
static HttpRequestFilter |
PASS_THROUGH_REQUEST_FILTER |
static String |
PATTERN_RFC1036
Date format pattern used to parse HTTP date headers in RFC 1036 format.
|
static String |
PATTERN_RFC1123
Date format pattern used to parse HTTP date headers in RFC 1123 format.
|
static String |
PROXY_ERROR_HEADERS
Constant for the headers for a proxy error response.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addVia(org.jboss.netty.handler.codec.http.HttpMessage msg)
Adds the Via header to specify that the message has passed through
the proxy.
|
static String |
cacheUri(org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
Builds the cache URI from the request, including the host and the path.
|
static void |
closeOnFlush(org.jboss.netty.channel.Channel ch)
Closes the specified channel after all queued write requests are flushed.
|
static org.jboss.netty.handler.codec.http.HttpRequest |
copyHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest original)
Creates a copy of an original HTTP request to void modifying it.
|
static org.jboss.netty.handler.codec.http.HttpRequest |
copyHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest original,
boolean keepProxyFormat)
Creates a copy of an original HTTP request to void modifying it.
|
static org.jboss.netty.handler.codec.http.HttpResponse |
copyMutableResponseFields(org.jboss.netty.handler.codec.http.HttpResponse original,
org.jboss.netty.handler.codec.http.HttpResponse copy)
Copies the mutable fields from the response original to the copy.
|
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 String |
parseHostAndPort(org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
Parses the host and port an HTTP request is being sent to.
|
static int |
parsePort(org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
Parses the port from an address.
|
static void |
printHeader(org.jboss.netty.handler.codec.http.HttpMessage msg,
String name)
Prints the specified header from the specified method.
|
static void |
printHeaders(org.jboss.netty.handler.codec.http.HttpMessage msg)
Prints the headers of the message (for debugging).
|
static void |
stripHopByHopHeaders(org.jboss.netty.handler.codec.http.HttpMessage msg)
Removes all headers that should not be forwarded.
|
static String |
stripHost(String uri)
Strips the host from a URI string.
|
static void |
writeResponse(org.jboss.netty.channel.Channel channel,
String statusLine,
String headers)
Writes a raw HTTP response to the channel.
|
static void |
writeResponse(org.jboss.netty.channel.Channel channel,
String statusLine,
String headers,
String responseBody)
Writes a raw HTTP response to the channel.
|
public static final String PATTERN_RFC1123
public static final String PATTERN_RFC1036
public static final org.jboss.netty.channel.ChannelFutureListener NO_OP_LISTENER
ChannelFutureListener.public static final String CONNECT_OK_HEADERS
public static final String PROXY_ERROR_HEADERS
public static final HttpRequestFilter PASS_THROUGH_REQUEST_FILTER
public static String stripHost(String uri)
uri - The URI to transform.public static String cacheUri(org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
httpRequest - The request.public static String formatDate(Date date)
date - The date to format.PATTERN_RFC1123public static String formatDate(Date date, String pattern)
simple date
format class.date - The date to format.pattern - The pattern to use for formatting the date.IllegalArgumentException - If the given date pattern is invalid.SimpleDateFormatpublic static String httpDate()
public static org.jboss.netty.handler.codec.http.HttpResponse copyMutableResponseFields(org.jboss.netty.handler.codec.http.HttpResponse original,
org.jboss.netty.handler.codec.http.HttpResponse copy)
original - The original response to copy from.copy - The copy.public static void writeResponse(org.jboss.netty.channel.Channel channel,
String statusLine,
String headers)
channel - The channel.statusLine - The status line of the response.headers - The raw headers string.public static void writeResponse(org.jboss.netty.channel.Channel channel,
String statusLine,
String headers,
String responseBody)
channel - The channel.statusLine - The status line of the response.headers - The raw headers string.responseBody - The response body.public static void printHeaders(org.jboss.netty.handler.codec.http.HttpMessage msg)
msg - The HttpMessage.public static void printHeader(org.jboss.netty.handler.codec.http.HttpMessage msg,
String name)
msg - The HTTP message.name - The name of the header to print.public static void closeOnFlush(org.jboss.netty.channel.Channel ch)
ch - The Channel to close.public static String parseHostAndPort(org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
httpRequest - The request.public static int parsePort(org.jboss.netty.handler.codec.http.HttpRequest httpRequest)
httpRequest - The request containing the URI.public static org.jboss.netty.handler.codec.http.HttpRequest copyHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest original,
boolean keepProxyFormat)
original - The original request.keepProxyFormat - keep proxy-formatted URI (used in chaining)public static void stripHopByHopHeaders(org.jboss.netty.handler.codec.http.HttpMessage msg)
msg - The message to strip headers from.public static org.jboss.netty.handler.codec.http.HttpRequest copyHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest original)
original - The original request.public static void addVia(org.jboss.netty.handler.codec.http.HttpMessage msg)
msg - The HTTP message.Copyright © 2009–2015 LittleShoot. All rights reserved.