use of org.eclipse.jetty.io.EndPoint in project jetty.project by eclipse.
the class HttpConnectionOverFCGI method process.
private void process(ByteBuffer buffer) {
try {
EndPoint endPoint = getEndPoint();
boolean looping = false;
while (true) {
if (!looping && parse(buffer))
return;
int read = endPoint.fill(buffer);
if (LOG.isDebugEnabled())
LOG.debug("Read {} bytes from {}", read, endPoint);
if (read > 0) {
if (parse(buffer))
return;
} else if (read == 0) {
releaseBuffer(buffer);
fillInterested();
return;
} else {
releaseBuffer(buffer);
shutdown();
return;
}
looping = true;
}
} catch (Exception x) {
if (LOG.isDebugEnabled())
LOG.debug(x);
releaseBuffer(buffer);
close(x);
}
}
use of org.eclipse.jetty.io.EndPoint in project jetty.project by eclipse.
the class SocketCustomizationListener method onOpened.
@Override
public void onOpened(Connection connection) {
EndPoint endp = connection.getEndPoint();
boolean ssl = false;
if (_ssl && endp instanceof DecryptedEndPoint) {
endp = ((DecryptedEndPoint) endp).getSslConnection().getEndPoint();
ssl = true;
}
if (endp instanceof SocketChannelEndPoint) {
Socket socket = ((SocketChannelEndPoint) endp).getSocket();
customize(socket, connection.getClass(), ssl);
}
}
use of org.eclipse.jetty.io.EndPoint in project jetty.project by eclipse.
the class SslConnectionFactory method newConnection.
@Override
public Connection newConnection(Connector connector, EndPoint endPoint) {
SSLEngine engine = _sslContextFactory.newSSLEngine(endPoint.getRemoteAddress());
engine.setUseClientMode(false);
SslConnection sslConnection = newSslConnection(connector, endPoint, engine);
sslConnection.setRenegotiationAllowed(_sslContextFactory.isRenegotiationAllowed());
configure(sslConnection, connector, endPoint);
ConnectionFactory next = connector.getConnectionFactory(_nextProtocol);
EndPoint decryptedEndPoint = sslConnection.getDecryptedEndPoint();
Connection connection = next.newConnection(connector, decryptedEndPoint);
decryptedEndPoint.setConnection(connection);
return sslConnection;
}
use of org.eclipse.jetty.io.EndPoint in project jetty.project by eclipse.
the class IPAccessHandler method handle.
/* ------------------------------------------------------------ */
/**
* Checks the incoming request against the whitelist and blacklist
*
* @see org.eclipse.jetty.server.handler.HandlerWrapper#handle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Get the real remote IP (not the one set by the forwarded headers (which may be forged))
HttpChannel channel = baseRequest.getHttpChannel();
if (channel != null) {
EndPoint endp = channel.getEndPoint();
if (endp != null) {
InetSocketAddress address = endp.getRemoteAddress();
if (address != null && !isAddrUriAllowed(address.getHostString(), baseRequest.getPathInfo())) {
response.sendError(HttpStatus.FORBIDDEN_403);
baseRequest.setHandled(true);
return;
}
}
}
getHandler().handle(target, baseRequest, request, response);
}
use of org.eclipse.jetty.io.EndPoint in project jetty.project by eclipse.
the class HttpSenderOverHTTP method sendContent.
@Override
protected void sendContent(HttpExchange exchange, HttpContent content, Callback callback) {
try {
HttpClient client = getHttpChannel().getHttpDestination().getHttpClient();
ByteBufferPool bufferPool = client.getByteBufferPool();
ByteBuffer chunk = null;
while (true) {
ByteBuffer contentBuffer = content.getByteBuffer();
boolean lastContent = content.isLast();
HttpGenerator.Result result = generator.generateRequest(null, null, chunk, contentBuffer, lastContent);
if (LOG.isDebugEnabled())
LOG.debug("Generated content ({} bytes) - {}/{}", contentBuffer == null ? -1 : contentBuffer.remaining(), result, generator);
switch(result) {
case NEED_CHUNK:
{
chunk = bufferPool.acquire(HttpGenerator.CHUNK_SIZE, false);
break;
}
case FLUSH:
{
EndPoint endPoint = getHttpChannel().getHttpConnection().getEndPoint();
if (chunk != null)
endPoint.write(new ByteBufferRecyclerCallback(callback, bufferPool, chunk), chunk, contentBuffer);
else
endPoint.write(callback, contentBuffer);
return;
}
case SHUTDOWN_OUT:
{
shutdownOutput();
break;
}
case CONTINUE:
{
if (lastContent)
break;
callback.succeeded();
return;
}
case DONE:
{
callback.succeeded();
return;
}
default:
{
throw new IllegalStateException(result.toString());
}
}
}
} catch (Throwable x) {
if (LOG.isDebugEnabled())
LOG.debug(x);
callback.failed(x);
}
}
Aggregations