Top Description Inners Fields Constructors Methods
org.eclipse.jetty.server

public Class LocalConnector

extends AbstractConnector
Class Inheritance
Imports
java.nio.ByteBuffer, java.nio.charset.StandardCharsets, java.util.concurrent.BlockingQueue, .CountDownLatch, .Executor, .LinkedBlockingQueue, .TimeUnit, java.util.function.Consumer, org.eclipse.jetty.http.HttpField, .HttpParser, .HttpVersion, org.eclipse.jetty.io.ByteArrayEndPoint, .ByteBufferPool, .Connection, org.eclipse.jetty.util.BufferUtil, .ByteArrayOutputStream2, org.eclipse.jetty.util.ssl.SslContextFactory, org.eclipse.jetty.util.thread.Scheduler

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 and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
private final BlockingQueue<LocalConnector.LocalEndPoint>
Inherited from org.eclipse.jetty.server.AbstractConnector:
LOG

Constructor Summary

AccessConstructor and Description
public
LocalConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, int acceptors, ConnectionFactory... factories)

public
public
LocalConnector(Server server, SslContextFactory.Server sslContextFactory)

public
LocalConnector(Server server, ConnectionFactory connectionFactory)

public
LocalConnector(Server server, ConnectionFactory connectionFactory, SslContextFactory.Server sslContextFactory)

Method Summary

Modifier and TypeMethod and Description
protected void
accept(int acceptorID)

Implements abstract org.eclipse.jetty.server.AbstractConnector.accept.

public LocalConnector.LocalEndPoint
public LocalConnector.LocalEndPoint

Returns:

the local endpoint
executeRequest
(String
the request
rawRequest
)

Execute a request and return the EndPoint through which multiple responses can be received or more input provided.

private LocalConnector.LocalEndPoint
public ByteBuffer

Returns:

ByteBuffer containing response or null.
getResponse
(ByteBuffer
The request to send
requestsBuffer
)

Get a single response using a parser to search for the end of the message.

public ByteBuffer

Returns:

ByteBuffer containing response or null.
getResponse
(ByteBuffer
The request to send
requestBuffer
,
long
The time to wait
time
,
TimeUnit
The units of the wait
unit
)

Get a single response using a parser to search for the end of the message.

public ByteBuffer

Returns:

ByteBuffer containing response or null.
getResponse
(ByteBuffer
The request to send
requestBuffer
,
boolean
True if the response is for a head request
head
,
long
The time to wait
time
,
TimeUnit
The units of the wait
unit
)

Get a single response using a parser to search for the end of the message.

public String

Returns:

ByteBuffer containing response or null.
getResponse
(String
The request to send
rawRequest
)

Get a single response using a parser to search for the end of the message.

public String

Returns:

ByteBuffer containing response or null.
getResponse
(String
The request to send
rawRequest
,
long
The time to wait
time
,
TimeUnit
The units of the wait
unit
)

Get a single response using a parser to search for the end of the message.

public String

Returns:

ByteBuffer containing response or null.
getResponse
(String
The request to send
rawRequest
,
boolean
True if the response is for a head request
head
,
long
The time to wait
time
,
TimeUnit
The units of the wait
unit
)

Get a single response using a parser to search for the end of the message.

public Object
getTransport()

Implements org.eclipse.jetty.server.Connector.getTransport.

Get the underlying socket, channel, buffer etc. for the connector..

Inherited from org.eclipse.jetty.server.AbstractConnector:
addConnectionFactoryaddFirstConnectionFactoryaddIfAbsentConnectionFactoryclearConnectionFactoriesdoStartdoStopgetAcceptorPriorityDeltagetAcceptorsgetByteBufferPoolgetConnectedEndPointsgetConnectionFactoriesgetConnectionFactorygetConnectionFactorygetDefaultConnectionFactorygetDefaultProtocolgetExecutorgetIdleTimeoutgetNamegetProtocolsgetSchedulergetServergetShutdownIdleTimeouthandleAcceptFailureinterruptAcceptorsisAcceptingisShutdownjoinjoinonEndPointClosedonEndPointOpenedremoveConnectionFactorysetAcceptingsetAcceptorPriorityDeltasetConnectionFactoriessetDefaultProtocolsetIdleTimeoutsetNamesetShutdownIdleTimeoutshutdowntoString

Field Detail

_connectsback to summary
private final BlockingQueue<LocalConnector.LocalEndPoint> _connects

Constructor Detail

LocalConnectorback to summary
public LocalConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, int acceptors, ConnectionFactory... factories)
LocalConnectorback to summary
public LocalConnector(Server server)
LocalConnectorback to summary
public LocalConnector(Server server, SslContextFactory.Server sslContextFactory)
LocalConnectorback to summary
public LocalConnector(Server server, ConnectionFactory connectionFactory)
LocalConnectorback to summary
public LocalConnector(Server server, ConnectionFactory connectionFactory, SslContextFactory.Server sslContextFactory)

Method Detail

acceptback to summary
protected void accept(int acceptorID) throws InterruptedException

Implements abstract org.eclipse.jetty.server.AbstractConnector.accept.

Annotations
@Override
connectback to summary
public LocalConnector.LocalEndPoint connect()
executeRequestback to summary
public LocalConnector.LocalEndPoint executeRequest(String rawRequest)

Execute a request and return the EndPoint through which multiple responses can be received or more input provided.

Parameters
rawRequest:String

the request

Returns:LocalConnector.LocalEndPoint

the local endpoint

executeRequestback to summary
private LocalConnector.LocalEndPoint executeRequest(ByteBuffer rawRequest)
getResponseback to summary
public ByteBuffer getResponse(ByteBuffer requestsBuffer) throws Exception

Get a single response using a parser to search for the end of the message.

Parameters
requestsBuffer:ByteBuffer

The request to send

Returns:ByteBuffer

ByteBuffer containing response or null.

Exceptions
Exception:
If there is a problem
getResponseback to summary
public ByteBuffer getResponse(ByteBuffer requestBuffer, long time, TimeUnit unit) throws Exception

Get a single response using a parser to search for the end of the message.

Parameters
requestBuffer:ByteBuffer

The request to send

time:long

The time to wait

unit:TimeUnit

The units of the wait

Returns:ByteBuffer

ByteBuffer containing response or null.

Exceptions
Exception:
If there is a problem
getResponseback to summary
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:ByteBuffer

The request to send

head:boolean

True if the response is for a head request

time:long

The time to wait

unit:TimeUnit

The units of the wait

Returns:ByteBuffer

ByteBuffer containing response or null.

Exceptions
Exception:
If there is a problem
getResponseback to summary
public String getResponse(String rawRequest) throws Exception

Get a single response using a parser to search for the end of the message.

Parameters
rawRequest:String

The request to send

Returns:String

ByteBuffer containing response or null.

Exceptions
Exception:
If there is a problem
getResponseback to summary
public String getResponse(String rawRequest, long time, TimeUnit unit) throws Exception

Get a single response using a parser to search for the end of the message.

Parameters
rawRequest:String

The request to send

time:long

The time to wait

unit:TimeUnit

The units of the wait

Returns:String

ByteBuffer containing response or null.

Exceptions
Exception:
If there is a problem
getResponseback to summary
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:String

The request to send

head:boolean

True if the response is for a head request

time:long

The time to wait

unit:TimeUnit

The units of the wait

Returns:String

ByteBuffer containing response or null.

Exceptions
Exception:
If there is a problem
getTransportback to summary
public Object getTransport()

Implements org.eclipse.jetty.server.Connector.getTransport.

Doc from org.eclipse.jetty.server.Connector.getTransport.

Get the underlying socket, channel, buffer etc. for the connector..

Returns:Object

the underlying socket, channel, buffer etc. for the connector.

Annotations
@Override
org.eclipse.jetty.server back to summary

public Class LocalConnector.LocalEndPoint

extends ByteArrayEndPoint
Class Inheritance

Local EndPoint

Field Summary

Modifier and TypeField and Description
private final CountDownLatch
private ByteBuffer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
protected void
public String

Returns:

Buffer containing full response or null for EOF;
getResponse
()

Wait for a response using a parser to detect the end of message

public String

Returns:

Buffer containing full response or null for EOF;
getResponse
(boolean
whether the request is a HEAD request
head
,
long
the maximum time to wait
time
,
TimeUnit
the time unit of the timeout argument
unit
)

Wait for a response using a parser to detect the end of message

public ByteBuffer

Returns:

the remaining response data buffer
getResponseData
()

Remaining output ByteBuffer after calls to getResponse() or waitForResponse(boolean, long, TimeUnit)

public void
onClose(Throwable
The reason for the close, or null if a normal close.
cause
)

Overrides org.eclipse.jetty.io.AbstractEndPoint.onClose.

Implements org.eclipse.jetty.io.EndPoint.onClose.

Callback method invoked when this EndPoint is closed.

public ByteBuffer

Returns:

Buffer containing full response or null for EOF;
waitForResponse
(boolean
whether the request is a HEAD request
head
,
long
the maximum time to wait
time
,
TimeUnit
the time unit of the timeout argument
unit
)

Wait for a response using a parser to detect the end of message

public ByteBuffer

Returns:

Buffer containing full response or null for EOF;
waitForResponse
(boolean
whether the request is a HEAD request
head
,
long
the maximum time to wait
time
,
TimeUnit
the time unit of the timeout argument
unit
,
Consumer<Integer>
a consumer to be called with the response's status code
statusConsumer
)

Wait for a response using a parser to detect the end of message

public void
public void
waitUntilClosedOrIdleFor(long idleFor, TimeUnit units)

Inherited from org.eclipse.jetty.io.ByteArrayEndPoint:
addInputaddInputaddInputaddInputAndExecuteaddInputAndExecuteaddInputEOFdoClosefillflushgetLocalSocketAddressgetOutputgetOutputStringgetOutputStringgetRemoteSocketAddressgetTransporthasMoreisGrowOutputneedsFillInterestonIncompleteFlushresetsetGrowOutputsetOutputtakeOutputtakeOutputStringtakeOutputStringtoStringwaitForOutput

Field Detail

_closedback to summary
private final CountDownLatch _closed
_responseDataback to summary
private ByteBuffer _responseData

Constructor Detail

LocalEndPointback to summary
public LocalEndPoint()

Method Detail

doShutdownOutputback to summary
public void doShutdownOutput()

Overrides org.eclipse.jetty.io.ByteArrayEndPoint.doShutdownOutput.

Annotations
@Override
executeback to summary
protected void execute(Runnable task)

Overrides org.eclipse.jetty.io.ByteArrayEndPoint.execute.

Annotations
@Override
getResponseback to summary
public String getResponse() throws Exception

Wait for a response using a parser to detect the end of message

Returns:String

Buffer containing full response or null for EOF;

Exceptions
Exception:
if the response cannot be parsed
getResponseback to summary
public String getResponse(boolean head, long time, TimeUnit unit) throws Exception

Wait for a response using a parser to detect the end of message

Parameters
head:boolean

whether the request is a HEAD request

time:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:String

Buffer containing full response or null for EOF;

Exceptions
Exception:
if the response cannot be parsed
getResponseDataback to summary
public ByteBuffer getResponseData()

Remaining output ByteBuffer after calls to getResponse() or waitForResponse(boolean, long, TimeUnit)

Returns:ByteBuffer

the remaining response data buffer

onCloseback to summary
public void onClose(Throwable cause)

Overrides org.eclipse.jetty.io.AbstractEndPoint.onClose.

Implements org.eclipse.jetty.io.EndPoint.onClose.

Doc from org.eclipse.jetty.io.EndPoint.onClose.

Callback method invoked when this EndPoint is closed.

Parameters
cause:Throwable

The reason for the close, or null if a normal close.

Annotations
@Override
waitForResponseback to summary
public ByteBuffer waitForResponse(boolean head, long time, TimeUnit unit) throws Exception

Wait for a response using a parser to detect the end of message

Parameters
head:boolean

whether the request is a HEAD request

time:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

Returns:ByteBuffer

Buffer containing full response or null for EOF;

Exceptions
Exception:
if the response cannot be parsed
waitForResponseback to summary
public ByteBuffer waitForResponse(boolean head, long time, TimeUnit unit, Consumer<Integer> statusConsumer) throws Exception

Wait for a response using a parser to detect the end of message

Parameters
head:boolean

whether the request is a HEAD request

time:long

the maximum time to wait

unit:TimeUnit

the time unit of the timeout argument

statusConsumer:Consumer<Integer>

a consumer to be called with the response's status code

Returns:ByteBuffer

Buffer containing full response or null for EOF;

Exceptions
Exception:
if the response cannot be parsed
waitUntilClosedback to summary
public void waitUntilClosed()
waitUntilClosedOrIdleForback to summary
public void waitUntilClosedOrIdleFor(long idleFor, TimeUnit units)