Package org.apache.catalina.connector
Class Connector
java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.connector.Connector
- All Implemented Interfaces:
MBeanRegistration
,JmxEnabled
,Lifecycle
Implementation of a Coyote connector.
- Author:
- Craig R. McClanahan, Remy Maucherat
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
Lifecycle.SingleUse
-
Field Summary
Modifier and TypeFieldDescriptionprotected Adapter
Coyote adapter.protected boolean
If this istrue
the '\' character will be permitted as a path delimiter.protected boolean
Do we allow TRACE ?protected long
Default timeout for asynchronous requests (ms).protected final String
Name of the protocol that was configured.protected boolean
The flag that controls recycling of the facades of the request processing objects.protected boolean
The "enable DNS lookups" flag for this Connector.protected boolean
If this istrue
then a call toResponse.getWriter()
if no character encoding has been specified will result in subsequent calls toResponse.getCharacterEncoding()
returningISO-8859-1
and theContent-Type
response header will include acharset=ISO-8859-1
component.static final String
protected int
The maximum number of parameters (GET plus POST) which will be automatically parsed by the container. 10000 by default.protected int
Maximum size of a POST which will be automatically parsed by the container. 2 MiB by default.protected int
Maximum size of a POST which will be saved by the container during authentication. 4 KiB by defaultprotected String
Comma-separated list of HTTP methods that will be parsed according to POST-style rules for application/x-www-form-urlencoded request bodies.A Set of methods determined byparseBodyMethods
.protected final ProtocolHandler
Coyote protocol handler.protected final String
Coyote Protocol handler class name.protected String
The server name to which we should pretend requests to this Connector were directed.protected int
The server port to which we should pretend requests to this Connector were directed.protected int
The redirect port for non-SSL to SSL redirects.protected String
The request scheme that will be set on all requests received through this connector.protected boolean
The secure connection flag that will be set on all requests received through this connector.protected Service
TheService
we are associated with (if any).protected static final StringManager
The string manager for this package.protected boolean
URI encoding as body.protected boolean
Flag to use IP-based virtual hosting.protected boolean
Is generation of X-Powered-By response header enabled/disabled?Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
-
Constructor Summary
ConstructorDescriptionDefaults to using HTTP/1.1 NIO implementation.Connector
(ProtocolHandler protocolHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSslHostConfig
(SSLHostConfig sslHostConfig) void
addUpgradeProtocol
(UpgradeProtocol upgradeProtocol) protected String
Create (or allocate) and return a Request object suitable for specifying the contents of a Request to the responsible Container.Create (or allocate) and return a Response object suitable for receiving the contents of a Response from the responsible Container.protected void
Sub-classes implement this method to perform any instance destruction required.boolean
boolean
long
boolean
protected String
Method implemented by sub-classes to identify the domain in which MBeans should be registered.boolean
boolean
int
int
int
int
int
protected String
Allow sub-classes to specify the key properties component of theObjectName
that will be used to register this component.int
getPort()
int
int
getProperty
(String name) Return a property from the protocol handler.int
int
int
boolean
boolean
boolean
boolean
Test if IP-based virtual hosting is enabled.boolean
Indicates whether the generation of an X-Powered-By response header for Servlet-generated responses is enabled or disabled for this Connector.protected void
Sub-classes implement this method to perform any instance initialisation required.protected boolean
isParseBodyMethod
(String method) void
pause()
Pause the connector.void
resume()
Resume the connector.void
setAllowBackslash
(boolean allowBackslash) Set the allowBackslash flag.void
setAllowTrace
(boolean allowTrace) Set the allowTrace flag, to disable or enable the TRACE HTTP method.void
setAsyncTimeout
(long asyncTimeout) Set the default timeout for async requests.void
setDiscardFacades
(boolean discardFacades) Set the recycling strategy for the object facades.void
setEnableLookups
(boolean enableLookups) Set the "enable DNS lookups" flag.void
setEncodedSolidusHandling
(String encodedSolidusHandling) void
setEnforceEncodingInGetWriter
(boolean enforceEncodingInGetWriter) Set the enforceEncodingInGetWriter flag.void
setMaxCookieCount
(int maxCookieCount) void
setMaxParameterCount
(int maxParameterCount) Set the maximum number of parameters (GET plus POST) that will be automatically parsed by the container.void
setMaxPostSize
(int maxPostSize) Set the maximum size of a POST which will be automatically parsed by the container.void
setMaxSavePostSize
(int maxSavePostSize) Set the maximum size of a POST which will be saved by the container during authentication.void
setParseBodyMethods
(String methods) Set list of HTTP methods which should allow body parameter parsing.void
setPort
(int port) Set the port number on which we listen for requests.void
setPortOffset
(int portOffset) boolean
setProperty
(String name, String value) Set a property on the protocol handler.void
setProxyName
(String proxyName) Set the proxy server name for this Connector.void
setProxyPort
(int proxyPort) Set the proxy server port for this Connector.void
setRedirectPort
(int redirectPort) Set the redirect port number.void
setRejectSuspiciousURIs
(boolean rejectSuspiciousURIs) void
Set the scheme that will be assigned to requests received through this connector.void
setSecure
(boolean secure) Set the secure connection flag that will be assigned to requests received through this connector.void
setService
(Service service) Set theService
with which we are associated (if any).void
setURIEncoding
(String URIEncoding) Set the URI encoding to be used for the URI.void
setUseBodyEncodingForURI
(boolean useBodyEncodingForURI) Set if the entity body encoding should be used for the URI.void
setUseIPVHosts
(boolean useIPVHosts) Enable the use of IP-based virtual hosting.void
setXpoweredBy
(boolean xpoweredBy) Enables or disables the generation of an X-Powered-By header (with value Servlet/2.5) for all servlet-generated responses returned by this Connector.protected void
Begin processing requests via this Connector.protected void
Terminate processing requests via this Connector.toString()
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
Methods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
-
Field Details
-
INTERNAL_EXECUTOR_NAME
- See Also:
-
service
TheService
we are associated with (if any). -
allowBackslash
protected boolean allowBackslashIf this istrue
the '\' character will be permitted as a path delimiter. If not specified, the default value offalse
will be used. -
allowTrace
protected boolean allowTraceDo we allow TRACE ? -
asyncTimeout
protected long asyncTimeoutDefault timeout for asynchronous requests (ms). -
enableLookups
protected boolean enableLookupsThe "enable DNS lookups" flag for this Connector. -
enforceEncodingInGetWriter
protected boolean enforceEncodingInGetWriterIf this istrue
then a call toResponse.getWriter()
if no character encoding has been specified will result in subsequent calls toResponse.getCharacterEncoding()
returningISO-8859-1
and theContent-Type
response header will include acharset=ISO-8859-1
component. (SRV.15.2.22.1) If not specified, the default specification compliant value oftrue
will be used. -
xpoweredBy
protected boolean xpoweredByIs generation of X-Powered-By response header enabled/disabled? -
proxyName
The server name to which we should pretend requests to this Connector were directed. This is useful when operating Tomcat behind a proxy server, so that redirects get constructed accurately. If not specified, the server name included in theHost
header is used. -
proxyPort
protected int proxyPortThe server port to which we should pretend requests to this Connector were directed. This is useful when operating Tomcat behind a proxy server, so that redirects get constructed accurately. If not specified, the port number specified by theport
property is used. -
discardFacades
protected boolean discardFacadesThe flag that controls recycling of the facades of the request processing objects. If set totrue
the object facades will be discarded when the request is recycled. If the security manager is enabled, this setting is ignored and object facades are always discarded. -
redirectPort
protected int redirectPortThe redirect port for non-SSL to SSL redirects. -
scheme
The request scheme that will be set on all requests received through this connector. -
secure
protected boolean secureThe secure connection flag that will be set on all requests received through this connector. -
sm
The string manager for this package. -
maxParameterCount
protected int maxParameterCountThe maximum number of parameters (GET plus POST) which will be automatically parsed by the container. 10000 by default. The default Tomcat server.xml configures a lower default of 1000. A value of less than 0 means no limit. -
maxPostSize
protected int maxPostSizeMaximum size of a POST which will be automatically parsed by the container. 2 MiB by default. -
maxSavePostSize
protected int maxSavePostSizeMaximum size of a POST which will be saved by the container during authentication. 4 KiB by default -
parseBodyMethods
Comma-separated list of HTTP methods that will be parsed according to POST-style rules for application/x-www-form-urlencoded request bodies. -
parseBodyMethodsSet
A Set of methods determined byparseBodyMethods
. -
useIPVHosts
protected boolean useIPVHostsFlag to use IP-based virtual hosting. -
protocolHandlerClassName
Coyote Protocol handler class name. SeeConnector()
for current default. -
configuredProtocol
Name of the protocol that was configured. -
protocolHandler
Coyote protocol handler. -
adapter
Coyote adapter. -
useBodyEncodingForURI
protected boolean useBodyEncodingForURIURI encoding as body.
-
-
Constructor Details
-
Connector
public Connector()Defaults to using HTTP/1.1 NIO implementation. -
Connector
-
Connector
-
-
Method Details
-
getProperty
-
setProperty
-
getService
- Returns:
- the
Service
with which we are associated (if any).
-
setService
Set theService
with which we are associated (if any).- Parameters:
service
- The service that owns this Engine
-
getAllowBackslash
public boolean getAllowBackslash()- Returns:
true
if backslash characters are allowed in URLs. Default value isfalse
.
-
setAllowBackslash
public void setAllowBackslash(boolean allowBackslash) Set the allowBackslash flag.- Parameters:
allowBackslash
- the new flag value
-
getAllowTrace
public boolean getAllowTrace()- Returns:
true
if the TRACE method is allowed. Default value isfalse
.
-
setAllowTrace
public void setAllowTrace(boolean allowTrace) Set the allowTrace flag, to disable or enable the TRACE HTTP method.- Parameters:
allowTrace
- The new allowTrace flag
-
getAsyncTimeout
public long getAsyncTimeout()- Returns:
- the default timeout for async requests in ms.
-
setAsyncTimeout
public void setAsyncTimeout(long asyncTimeout) Set the default timeout for async requests.- Parameters:
asyncTimeout
- The new timeout in ms.
-
getDiscardFacades
public boolean getDiscardFacades()- Returns:
true
if the object facades are discarded, either when the discardFacades value istrue
or when the security manager is enabled.
-
setDiscardFacades
public void setDiscardFacades(boolean discardFacades) Set the recycling strategy for the object facades.- Parameters:
discardFacades
- the new value of the flag
-
getEnableLookups
public boolean getEnableLookups()- Returns:
- the "enable DNS lookups" flag.
-
setEnableLookups
public void setEnableLookups(boolean enableLookups) Set the "enable DNS lookups" flag.- Parameters:
enableLookups
- The new "enable DNS lookups" flag value
-
getEnforceEncodingInGetWriter
public boolean getEnforceEncodingInGetWriter()- Returns:
true
if a default character encoding will be set when calling Response.getWriter()
-
setEnforceEncodingInGetWriter
public void setEnforceEncodingInGetWriter(boolean enforceEncodingInGetWriter) Set the enforceEncodingInGetWriter flag.- Parameters:
enforceEncodingInGetWriter
- the new flag value
-
getMaxCookieCount
public int getMaxCookieCount() -
setMaxCookieCount
public void setMaxCookieCount(int maxCookieCount) -
getMaxParameterCount
public int getMaxParameterCount()- Returns:
- the maximum number of parameters (GET plus POST) that will be automatically parsed by the container. A value of less than 0 means no limit.
-
setMaxParameterCount
public void setMaxParameterCount(int maxParameterCount) Set the maximum number of parameters (GET plus POST) that will be automatically parsed by the container. A value of less than 0 means no limit.- Parameters:
maxParameterCount
- The new setting
-
getMaxPostSize
public int getMaxPostSize()- Returns:
- the maximum size of a POST which will be automatically parsed by the container.
-
setMaxPostSize
public void setMaxPostSize(int maxPostSize) Set the maximum size of a POST which will be automatically parsed by the container.- Parameters:
maxPostSize
- The new maximum size in bytes of a POST which will be automatically parsed by the container
-
getMaxSavePostSize
public int getMaxSavePostSize()- Returns:
- the maximum size of a POST which will be saved by the container during authentication.
-
setMaxSavePostSize
public void setMaxSavePostSize(int maxSavePostSize) Set the maximum size of a POST which will be saved by the container during authentication.- Parameters:
maxSavePostSize
- The new maximum size in bytes of a POST which will be saved by the container during authentication.
-
getParseBodyMethods
- Returns:
- the HTTP methods which will support body parameters parsing
-
setParseBodyMethods
Set list of HTTP methods which should allow body parameter parsing. This defaults toPOST
.- Parameters:
methods
- Comma separated list of HTTP method names
-
isParseBodyMethod
-
getPort
public int getPort()- Returns:
- the port number on which this connector is configured to listen for requests. The special value of 0 means select a random free port when the socket is bound.
-
setPort
public void setPort(int port) Set the port number on which we listen for requests.- Parameters:
port
- The new port number
-
getPortOffset
public int getPortOffset() -
setPortOffset
public void setPortOffset(int portOffset) -
getPortWithOffset
public int getPortWithOffset() -
getLocalPort
public int getLocalPort()- Returns:
- the port number on which this connector is listening to requests. If the special value for
getPort()
of zero is used then this method will report the actual port bound.
-
getProtocol
- Returns:
- the Coyote protocol handler in use.
-
getProtocolHandlerClassName
- Returns:
- the class name of the Coyote protocol handler in use.
-
getProtocolHandler
- Returns:
- the protocol handler associated with the connector.
-
getProxyName
- Returns:
- the proxy server name for this Connector.
-
setProxyName
Set the proxy server name for this Connector.- Parameters:
proxyName
- The new proxy server name
-
getProxyPort
public int getProxyPort()- Returns:
- the proxy server port for this Connector.
-
setProxyPort
public void setProxyPort(int proxyPort) Set the proxy server port for this Connector.- Parameters:
proxyPort
- The new proxy server port
-
getRedirectPort
public int getRedirectPort()- Returns:
- the port number to which a request should be redirected if it comes in on a non-SSL port and is subject to a security constraint with a transport guarantee that requires SSL.
-
setRedirectPort
public void setRedirectPort(int redirectPort) Set the redirect port number.- Parameters:
redirectPort
- The redirect port number (non-SSL to SSL)
-
getRedirectPortWithOffset
public int getRedirectPortWithOffset() -
getScheme
- Returns:
- the scheme that will be assigned to requests received through this connector. Default value is "http".
-
setScheme
Set the scheme that will be assigned to requests received through this connector.- Parameters:
scheme
- The new scheme
-
getSecure
public boolean getSecure()- Returns:
- the secure connection flag that will be assigned to requests received through this connector. Default value is "false".
-
setSecure
public void setSecure(boolean secure) Set the secure connection flag that will be assigned to requests received through this connector.- Parameters:
secure
- The new secure connection flag
-
getURIEncoding
- Returns:
- the name of character encoding to be used for the URI using the original case.
-
getURICharset
- Returns:
- The Charset to use to convert raw URI bytes (after %nn decoding) to characters. This will never be null
-
setURIEncoding
Set the URI encoding to be used for the URI.- Parameters:
URIEncoding
- The new URI character encoding.
-
getUseBodyEncodingForURI
public boolean getUseBodyEncodingForURI()- Returns:
- the true if the entity body encoding should be used for the URI.
-
setUseBodyEncodingForURI
public void setUseBodyEncodingForURI(boolean useBodyEncodingForURI) Set if the entity body encoding should be used for the URI.- Parameters:
useBodyEncodingForURI
- The new value for the flag.
-
getXpoweredBy
public boolean getXpoweredBy()Indicates whether the generation of an X-Powered-By response header for Servlet-generated responses is enabled or disabled for this Connector.- Returns:
true
if generation of X-Powered-By response header is enabled, false otherwise
-
setXpoweredBy
public void setXpoweredBy(boolean xpoweredBy) Enables or disables the generation of an X-Powered-By header (with value Servlet/2.5) for all servlet-generated responses returned by this Connector.- Parameters:
xpoweredBy
- true if generation of X-Powered-By response header is to be enabled, false otherwise
-
setUseIPVHosts
public void setUseIPVHosts(boolean useIPVHosts) Enable the use of IP-based virtual hosting.- Parameters:
useIPVHosts
-true
if Hosts are identified by IP,false
if Hosts are identified by name.
-
getUseIPVHosts
public boolean getUseIPVHosts()Test if IP-based virtual hosting is enabled.- Returns:
true
if IP vhosts are enabled
-
getExecutorName
-
addSslHostConfig
-
findSslHostConfigs
-
addUpgradeProtocol
-
findUpgradeProtocols
-
getEncodedSolidusHandling
-
setEncodedSolidusHandling
-
getEncodedSolidusHandlingInternal
-
getRejectSuspiciousURIs
public boolean getRejectSuspiciousURIs() -
setRejectSuspiciousURIs
public void setRejectSuspiciousURIs(boolean rejectSuspiciousURIs) -
createRequest
Create (or allocate) and return a Request object suitable for specifying the contents of a Request to the responsible Container.- Returns:
- a new Servlet request object
-
createResponse
Create (or allocate) and return a Response object suitable for receiving the contents of a Response from the responsible Container.- Returns:
- a new Servlet response object
-
createObjectNameKeyProperties
-
pause
public void pause()Pause the connector. -
resume
public void resume()Resume the connector. -
initInternal
Description copied from class:LifecycleBase
Sub-classes implement this method to perform any instance initialisation required.- Overrides:
initInternal
in classLifecycleMBeanBase
- Throws:
LifecycleException
- If the initialisation fails
-
startInternal
Begin processing requests via this Connector.- Specified by:
startInternal
in classLifecycleBase
- Throws:
LifecycleException
- if a fatal startup error occurs
-
stopInternal
Terminate processing requests via this Connector.- Specified by:
stopInternal
in classLifecycleBase
- Throws:
LifecycleException
- if a fatal shutdown error occurs
-
destroyInternal
Description copied from class:LifecycleBase
Sub-classes implement this method to perform any instance destruction required.- Overrides:
destroyInternal
in classLifecycleMBeanBase
- Throws:
LifecycleException
- If the destruction fails
-
toString
-
getDomainInternal
Description copied from class:LifecycleMBeanBase
Method implemented by sub-classes to identify the domain in which MBeans should be registered.- Specified by:
getDomainInternal
in classLifecycleMBeanBase
- Returns:
- The name of the domain to use to register MBeans.
-
getObjectNameKeyProperties
Description copied from class:LifecycleMBeanBase
Allow sub-classes to specify the key properties component of theObjectName
that will be used to register this component.- Specified by:
getObjectNameKeyProperties
in classLifecycleMBeanBase
- Returns:
- The string representation of the key properties component of the desired
ObjectName
-