org.eclipse.jetty.server.AbstractHttpConnection Java Examples

The following examples show how to use org.eclipse.jetty.server.AbstractHttpConnection. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JettyServletContainer.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
public static boolean isConnectionOpen(HttpServletRequest request, byte[] heartbeat) {
    Request jettyRequest = (Request)request;
    AbstractHttpConnection connection = jettyRequest.getConnection();
    Socket socket = (Socket)connection.getEndPoint().getTransport();
    if (log.isLoggable(Level.FINE))
        log.fine("Checking if client connection is still open: " + socket.getRemoteSocketAddress());
    try {
        socket.getOutputStream().write(heartbeat);
        socket.getOutputStream().flush();
        return true;
    } catch (IOException ex) {
        if (log.isLoggable(Level.FINE))
            log.fine("Client connection has been closed: " + socket.getRemoteSocketAddress());
        return false;
    }
}
 
Example #2
Source File: AndroidJettyServletContainer.java    From BeyondUPnP with Apache License 2.0 6 votes vote down vote up
public static boolean isConnectionOpen(HttpServletRequest request, byte[] heartbeat) {
    Request jettyRequest = (Request) request;
    AbstractHttpConnection connection = jettyRequest.getConnection();
    Socket socket = (Socket) connection.getEndPoint().getTransport();
    if (log.isLoggable(Level.FINE))
        log.fine("Checking if client connection is still open: " + socket.getRemoteSocketAddress());
    try {
        socket.getOutputStream().write(heartbeat);
        socket.getOutputStream().flush();
        return true;
    } catch (IOException ex) {
        if (log.isLoggable(Level.FINE))
            log.fine("Client connection has been closed: " + socket.getRemoteSocketAddress());
        return false;
    }
}
 
Example #3
Source File: JettyServletContainer.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
public static boolean isConnectionOpen(HttpServletRequest request, byte[] heartbeat) {
    Request jettyRequest = (Request)request;
    AbstractHttpConnection connection = jettyRequest.getConnection();
    Socket socket = (Socket)connection.getEndPoint().getTransport();
    if (log.isLoggable(Level.FINE))
        log.fine("Checking if client connection is still open: " + socket.getRemoteSocketAddress());
    try {
        socket.getOutputStream().write(heartbeat);
        socket.getOutputStream().flush();
        return true;
    } catch (IOException ex) {
        if (log.isLoggable(Level.FINE))
            log.fine("Client connection has been closed: " + socket.getRemoteSocketAddress());
        return false;
    }
}
 
Example #4
Source File: Jetty8xServerHandleInterceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
HttpServletRequest toHttpServletRequest(Object[] args) {
    if (args == null || args.length < 1) {
        return null;
    }

    if (args[0] instanceof AbstractHttpConnection) {
        try {
            AbstractHttpConnection connection = (AbstractHttpConnection) args[0];
            return connection.getRequest();
        } catch (Throwable ignored) {
        }
    }
    return null;
}
 
Example #5
Source File: Jetty8xServerHandleInterceptor.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
HttpServletResponse toHttpServletResponse(Object[] args) {
    if (args == null || args.length < 1) {
        return null;
    }

    if (args[0] instanceof AbstractHttpConnection) {
        try {
            AbstractHttpConnection connection = (AbstractHttpConnection) args[0];
            return connection.getResponse();
        } catch (Throwable ignored) {
        }
    }
    return null;
}