Package org.eclipse.jetty.server
Class LocalConnector
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.AbstractConnector
org.eclipse.jetty.server.LocalConnector
- All Implemented Interfaces:
Connector
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,Graceful
,LifeCycle
A local connector, mostly for testing purposes.
HttpTester.Request request = HttpTester.newRequest(); request.setURI("/some/resource"); HttpTester.Response response = HttpTester.parseResponse(HttpTester.from(localConnector.getResponse(request.generate())));
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful
Graceful.Shutdown
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
FieldsFields inherited from class org.eclipse.jetty.server.AbstractConnector
LOG
-
Constructor Summary
ConstructorsConstructorDescriptionLocalConnector
(Server server) LocalConnector
(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories) LocalConnector
(Server server, ConnectionFactory connectionFactory) LocalConnector
(Server server, ConnectionFactory connectionFactory, SslContextFactory sslContextFactory) LocalConnector
(Server server, SslContextFactory sslContextFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
accept
(int acceptorID) connect()
executeRequest
(String rawRequest) Execute a request and return the EndPoint through which multiple responses can be received or more input provided.private LocalConnector.LocalEndPoint
executeRequest
(ByteBuffer rawRequest) getResponse
(String rawRequest) Get a single response using a parser to search for the end of the message.getResponse
(String rawRequest, boolean head, long time, TimeUnit unit) Get a single response using a parser to search for the end of the message.getResponse
(String rawRequest, long time, TimeUnit unit) Get a single response using a parser to search for the end of the message.getResponse
(ByteBuffer requestsBuffer) Get a single response using a parser to search for the end of the message.getResponse
(ByteBuffer requestBuffer, boolean head, long time, TimeUnit unit) Get a single response using a parser to search for the end of the message.getResponse
(ByteBuffer requestBuffer, long time, TimeUnit unit) Get a single response using a parser to search for the end of the message.getResponses
(String requests) Deprecated.getResponses
(String requests, long idleFor, TimeUnit units) Deprecated.getResponses
(ByteBuffer requestsBuffer) Deprecated.getResponses
(ByteBuffer requestsBuffer, long idleFor, TimeUnit units) Deprecated.Methods inherited from class org.eclipse.jetty.server.AbstractConnector
addConnectionFactory, addFirstConnectionFactory, addIfAbsentConnectionFactory, clearConnectionFactories, doStart, doStop, getAcceptorPriorityDelta, getAcceptors, getByteBufferPool, getConnectedEndPoints, getConnectionFactories, getConnectionFactory, getConnectionFactory, getDefaultConnectionFactory, getDefaultProtocol, getExecutor, getHttpChannelListeners, getIdleTimeout, getName, getProtocols, getScheduler, getServer, handleAcceptFailure, interruptAcceptors, isAccepting, isShutdown, join, join, onEndPointClosed, onEndPointOpened, removeConnectionFactory, setAccepting, setAcceptorPriorityDelta, setConnectionFactories, setDefaultProtocol, setIdleTimeout, setName, shutdown, toString
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Container
addBean, addBean, addEventListener, getBean, getBeans, getBeans, getContainedBeans, isManaged, manage, removeBean, removeEventListener, unmanage
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Field Details
-
_connects
-
-
Constructor Details
-
LocalConnector
public LocalConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories) -
LocalConnector
-
LocalConnector
-
LocalConnector
-
LocalConnector
public LocalConnector(Server server, ConnectionFactory connectionFactory, SslContextFactory sslContextFactory)
-
-
Method Details
-
getTransport
- Returns:
- the underlying socket, channel, buffer etc. for the connector.
-
getResponses
Deprecated.Sends requests and get responses based on thread activity. Returns all the responses received once the thread activity has returned to the level it was before the requests.This methods waits until the connection is closed or is idle for 5s before returning the responses.
Use
getResponse(String)
for an alternative that does not wait for idle.- Parameters:
requests
- the requests- Returns:
- the responses
- Throws:
Exception
- if the requests fail
-
getResponses
@Deprecated public String getResponses(String requests, long idleFor, TimeUnit units) throws Exception Deprecated.Sends requests and get responses based on thread activity. Returns all the responses received once the thread activity has returned to the level it was before the requests.This methods waits until the connection is closed or an idle period before returning the responses.
Use
getResponse(String)
for an alternative that does not wait for idle.- Parameters:
requests
- the requestsidleFor
- The time the response stream must be idle for before returningunits
- The units of idleFor- Returns:
- the responses
- Throws:
Exception
- if the requests fail
-
getResponses
Deprecated.Sends requests and get's responses based on thread activity. Returns all the responses received once the thread activity has returned to the level it was before the requests.This methods waits until the connection is closed or is idle for 5s before returning the responses.
Use
getResponse(ByteBuffer)
for an alternative that does not wait for idle.- Parameters:
requestsBuffer
- the requests- Returns:
- the responses
- Throws:
Exception
- if the requests fail
-
getResponses
@Deprecated public ByteBuffer getResponses(ByteBuffer requestsBuffer, long idleFor, TimeUnit units) throws Exception Deprecated.Sends requests and get's responses based on thread activity. Returns all the responses received once the thread activity has returned to the level it was before the requests.This methods waits until the connection is closed or an idle period before returning the responses.
- Parameters:
requestsBuffer
- the requestsidleFor
- The time the response stream must be idle for before returningunits
- The units of idleFor- Returns:
- the responses
- Throws:
Exception
- if the requests fail
-
executeRequest
Execute a request and return the EndPoint through which multiple responses can be received or more input provided.- Parameters:
rawRequest
- the request- Returns:
- the local endpoint
-
executeRequest
-
connect
-
accept
- Specified by:
accept
in classAbstractConnector
- Throws:
IOException
InterruptedException
-
getResponse
Get a single response using a parser to search for the end of the message.- Parameters:
requestsBuffer
- The request to send- Returns:
- ByteBuffer containing response or null.
- Throws:
Exception
- If there is a problem
-
getResponse
Get a single response using a parser to search for the end of the message.- Parameters:
requestBuffer
- The request to sendtime
- The time to waitunit
- The units of the wait- Returns:
- ByteBuffer containing response or null.
- Throws:
Exception
- If there is a problem
-
getResponse
public ByteBuffer getResponse(ByteBuffer requestBuffer, boolean head, long time, TimeUnit unit) throws Exception Get a single response using a parser to search for the end of the message.- Parameters:
requestBuffer
- The request to sendhead
- True if the response is for a head requesttime
- The time to waitunit
- The units of the wait- Returns:
- ByteBuffer containing response or null.
- Throws:
Exception
- If there is a problem
-
getResponse
Get a single response using a parser to search for the end of the message.- Parameters:
rawRequest
- The request to send- Returns:
- ByteBuffer containing response or null.
- Throws:
Exception
- If there is a problem
-
getResponse
Get a single response using a parser to search for the end of the message.- Parameters:
rawRequest
- The request to sendtime
- The time to waitunit
- The units of the wait- Returns:
- ByteBuffer containing response or null.
- Throws:
Exception
- If there is a problem
-
getResponse
public String getResponse(String rawRequest, boolean head, long time, TimeUnit unit) throws Exception Get a single response using a parser to search for the end of the message.- Parameters:
rawRequest
- The request to sendhead
- True if the response is for a head requesttime
- The time to waitunit
- The units of the wait- Returns:
- ByteBuffer containing response or null.
- Throws:
Exception
- If there is a problem
-
getResponse(String)