public class HttpProxyHandler extends AbstractProxyHandler
| Constructor and Description |
|---|
HttpProxyHandler(URI uri)
Constructs an HTTP tunnel connection handler with the default (10 seconds)
connection timeout.
|
HttpProxyHandler(URI uri,
ISessionConfig config)
Constructs an HTTP tunnel connection handler with the default (10 seconds)
connection timeout and configuration.
|
HttpProxyHandler(URI uri,
ISessionConfig config,
ISessionStructureFactory factory)
Constructs an HTTP tunnel connection handler with the default (10 seconds)
connection timeout, configuration and factory.
|
HttpProxyHandler(URI uri,
String username,
String password)
Constructs an HTTP tunnel connection handler with the default (10 seconds)
connection timeout and user's name/password for the 'Basic' HTTP
authentication scheme.
|
HttpProxyHandler(URI uri,
String username,
String password,
ISessionConfig config)
Constructs an HTTP tunnel connection handler with the default (10 seconds)
connection timeout, user's name/password for the 'Basic' HTTP authentication
scheme and configuration.
|
HttpProxyHandler(URI uri,
String username,
String password,
ISessionConfig config,
ISessionStructureFactory factory)
Constructs an HTTP tunnel connection handler with the default (10 seconds)
connection timeout, user's name/password for the 'Basic' HTTP authentication
scheme, configuration and factory.
|
| Modifier and Type | Method and Description |
|---|---|
HttpProxyHandler |
allowBothTerminators(boolean allow)
Configures the handling of line terminators in responses from a HTTP proxy
server
|
void |
appendHeader(String name,
String value)
Appends an HTTP header to the HTTP CONNECT method request being sent to an
HTTP proxy server.
|
int |
available(byte[] data,
int off,
int len)
Determines how many bytes can be read from the input buffer after
receiving new data from the remote end.
|
HttpProxyHandler |
connectionTimeout(long connectionTimeout)
Configures the proxy connection timeout.
|
void |
event(SessionEvent event)
Called to notify about a change of the associated session state.
|
protected int |
getDefaultPort(URI uri)
Returns the default port number associated with the scheme in the provided
URI.
|
protected void |
handleReady()
Called to initiate the connection process via a proxy protocol
|
void |
read(byte[] data)
Called when new bytes were read from the input buffer.
|
void |
read(ByteBuffer data)
Called when new bytes were read from the input buffer.
|
void |
read(Object msg)
Called when a new message was read and decoded from the input buffer.
|
available, getFactory, timergetSession, setSessionevent, exception, getConfig, getName, incident, timerpublic HttpProxyHandler(URI uri)
NOTE: The connection timeout will have no effect if the associated session does not support a session timer.
uri - the URI identifying the remote host to which the HTTP tunnel
should be establishedIllegalArgumentException - if the uri is nullpublic HttpProxyHandler(URI uri, String username, String password)
NOTE: The connection timeout will have no effect if the associated session does not support a session timer.
uri - the URI identifying the remote host to which the HTTP tunnel
should be establishedusername - the user's namepassword - the user's passwordIllegalArgumentException - if the uri, username or password is nullpublic HttpProxyHandler(URI uri, ISessionConfig config)
NOTE: The connection timeout will have no effect if the associated session does not support a session timer.
uri - the URI identifying the remote host to which the HTTP tunnel
should be establishedconfig - the session configuration object, or null to use the
default configurationIllegalArgumentException - if the uri is nullpublic HttpProxyHandler(URI uri, String username, String password, ISessionConfig config)
NOTE: The connection timeout will have no effect if the associated session does not support a session timer.
uri - the URI identifying the remote host to which the HTTP tunnel
should be establishedusername - the user's namepassword - the user's passwordconfig - the session configuration object, or null to use the
default configurationIllegalArgumentException - if the uri, username or password is nullpublic HttpProxyHandler(URI uri, ISessionConfig config, ISessionStructureFactory factory)
NOTE: The connection timeout will have no effect if the associated session does not support a session timer.
uri - the URI identifying the remote host to which the HTTP tunnel
should be establishedconfig - the session configuration object, or null to use the
default configurationfactory - the factory that will be used to configure the internal
structure of the associated session, or null to use
the default factoryIllegalArgumentException - if the uri is nullpublic HttpProxyHandler(URI uri, String username, String password, ISessionConfig config, ISessionStructureFactory factory)
NOTE: The connection timeout will have no effect if the associated session does not support a session timer.
uri - the URI identifying the remote host to which the HTTP tunnel
should be establishedusername - the user's namepassword - the user's passwordconfig - the session configuration object, or null to use the
default configurationfactory - the factory that will be used to configure the internal
structure of the associated session, or null to use
the default factoryIllegalArgumentException - if the uri, username or password is nullpublic HttpProxyHandler connectionTimeout(long connectionTimeout)
NOTE: The connection timeout will have no effect if the associated session does not support a session timer.
connectionTimeout in class AbstractProxyHandlerconnectionTimeout - the proxy connection timeout in milliseconds, or 0
to wait an infinite amount of time for establishing
the HTTP tunnelIllegalArgumentException - if the connection timeout is negativepublic HttpProxyHandler allowBothTerminators(boolean allow)
allow - true to allow both CRLF and LF line terminators in
responses from a HTTP proxy server, or otherwise (default
option) only CRLF will be allowed.public int available(byte[] data,
int off,
int len)
AbstractStreamHandlerread method.
This method is called only if the input buffer is backed by an array. The
type of the input buffer is specified by the implementation of the
ISessionStructureFactory returned by the
getFactory method.
The content of the passed buffer cannot be changed by this method.
This implementation always returns total number of bytes in the array
(i.e. the len value).
available in interface IStreamReaderavailable in class AbstractStreamHandlerdata - the array that backs the input buffer.off - the offset of the arraylen - the number of the bytes in the arraypublic void read(byte[] data)
AbstractHandlerread methods are
met.
The passed array can be safely stored or modified by this method as it will not be used by the caller.
By default it simply passes the data value to the
IHandler.read(Object) method.
read in interface IHandlerread in interface IStreamReaderread in class AbstractHandlerdata - bytes that was read from the input buffer.public void read(ByteBuffer data)
AbstractHandlerByteBuffer objects or when the associated
session is configured to optimize data copying and uses an allocator
supporting the releasing of no longer used buffers
The passed byte buffer can be safely stored or modified by this method as it will not be used by the caller. However, if the associated session is configured to optimize data copying and uses an allocator supporting the releasing of no longer used buffers it may be required to release it in this method unless the original buffer has been already released by one of the associated decoders.
By default it simply passes the data value to the
IHandler.read(Object) method.
read in interface IHandlerread in interface IStreamReaderread in class AbstractHandlerdata - bytes that was read from the input buffer.public void event(SessionEvent event)
IHandlerevent in interface IHandlerevent in class AbstractProxyHandlerevent - an event related with the change of the session stateSessionEventpublic void appendHeader(String name, String value)
There is no need to append the Host header as it is appended by default.
name - the name of the HTTP headervalue - the value of the HTTP headerprotected int getDefaultPort(URI uri) throws Exception
By default it calls uri.toURL().getDefaultPort()
uri - the provided URI-1 if the default port number is
not defined for the scheme in the provided URIException - if the provided URI was malformedprotected void handleReady()
throws Exception
AbstractProxyHandlerhandleReady in class AbstractProxyHandlerException - if a failure occurredpublic void read(Object msg)
IHandlerbyte[] and ByteBuffer.msg - the message that was read and decoded from the input buffer.Copyright © 2017–2022 SNF4J.ORG. All rights reserved.