Example usage for org.apache.http.nio NHttpServerConnection equals

List of usage examples for org.apache.http.nio NHttpServerConnection equals

Introduction

In this page you can find the example usage for org.apache.http.nio NHttpServerConnection equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.opcfoundation.ua.transport.https.HttpsServerEndpointHandler.java

@Override
public void handle(HttpRequest request, HttpAsyncExchange httpExchange, HttpContext context)
        throws HttpException, IOException {

    String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
    if (!method.equals("POST")) {
        throw new MethodNotSupportedException(method + " method not supported");
    }/*ww  w. java  2 s  .co m*/

    HttpsServerPendingRequest req = new HttpsServerPendingRequest(this, httpExchange, request,
            singleSecureChannel, requestIdCounter.getAndIncrement());
    pendingRequests.put(req.requestId, req);

    //Check isDebugEnabled() here for possible performance reasons.
    //if (logger.isDebugEnabled()) {
    // Request URI is already set.
    //String requestUri = request.getRequestLine().getUri();
    //requestUri = URLDecoder.decode(requestUri, "UTF-8");            
    NHttpServerConnection connection = (NHttpServerConnection) context.getAttribute("http.connection");
    //logger.debug(method+" "+requestUri+"from"+connection);          
    logger.debug("handle: {} context={}: {}", connection, connection.getContext(), request);
    //}

    HttpsServerConnection currentConnection = (HttpsServerConnection) singleSecureChannel.getConnection();

    if (currentConnection == null || !connection.equals(currentConnection.getNHttpServerConnection())) {
        HttpsServerConnection httpsConnection = new HttpsServerConnection(this.endpointServer, connection);
        singleSecureChannel.setConnection(httpsConnection);
        logger.info("HttpsServerEndpointHandler.handle(): singleSecureChannel.setConnection({})", connection);
    }
    // Run in worker thread.
    //StackUtils.getBlockingWorkExecutor().execute( req );
    // Run in current thread
    req.run();
}