Package com.netflix.zuul.util
Class HttpUtils
java.lang.Object
com.netflix.zuul.util.HttpUtils
User: Mike Smith
Date: 4/28/15
Time: 11:05 PM
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
acceptsGzip
(Headers headers) static String
extractClientIpFromXForwardedFor
(String xForwardedFor) Extract the client IP address from an x-forwarded-for header.static Integer
static String
getClientIP
(HttpRequestInfo request) Get the IP address of client making the request.static Integer
static io.netty.channel.Channel
getMainChannel
(io.netty.channel.Channel channel) static io.netty.channel.Channel
getMainChannel
(io.netty.channel.ChannelHandlerContext ctx) If http/1 then will always want to just use ChannelHandlerContext.channel(), but for http/2 will want the parent channel (as the child channel is different for each h2 stream).static boolean
static boolean
static boolean
isCompressed
(Headers headers) static String
stripMaliciousHeaderChars
(String input) Ensure decoded new lines are not propagated in headers, in order to prevent XSS
-
Constructor Details
-
HttpUtils
public HttpUtils()
-
-
Method Details
-
getClientIP
Get the IP address of client making the request. Uses the "x-forwarded-for" HTTP header if available, otherwise uses the remote IP of requester.- Parameters:
request
-HttpRequestMessage
- Returns:
String
IP address
-
extractClientIpFromXForwardedFor
Extract the client IP address from an x-forwarded-for header. Returns null if there is no x-forwarded-for header- Parameters:
xForwardedFor
- aString
value- Returns:
- a
String
value
-
isCompressed
-
acceptsGzip
-
stripMaliciousHeaderChars
Ensure decoded new lines are not propagated in headers, in order to prevent XSS- Parameters:
input
- - decoded header string- Returns:
- - clean header string
-
hasNonZeroContentLengthHeader
-
getContentLengthIfPresent
-
getBodySizeIfKnown
-
hasChunkedTransferEncodingHeader
-
getMainChannel
public static io.netty.channel.Channel getMainChannel(io.netty.channel.ChannelHandlerContext ctx) If http/1 then will always want to just use ChannelHandlerContext.channel(), but for http/2 will want the parent channel (as the child channel is different for each h2 stream). -
getMainChannel
public static io.netty.channel.Channel getMainChannel(io.netty.channel.Channel channel)
-