<p>
Provide additional response processing
</p>

@param vertxResponse  the vert.x http server response
@param jerseyResponse the jersey container response
165606
@Override
    public void process(HttpServerResponse vertxResponse, ContainerResponse jerseyResponse) {
        Object obj = jerseyResponse.getRequestContext().getProperty(RequestProcessor.LAST_BYTE_TIMER_CONTEXT);
        if (obj instanceof Timer.Context) {
            Timer.Context context = (Timer.Context) obj;
            context.stop();
        }
    }
109935
@SuppressWarnings("unchecked")
  private <T extends Request> void handleResponse(T request, BiFunction sender, Connection connection, Response response, Throwable error, CompletableFuture future) {
    if (open) {
      if (error == null) {
        if (response.status() == Response.Status.OK
          || response.error() == CopycatError.Type.COMMAND_ERROR
          || response.error() == CopycatError.Type.QUERY_ERROR
          || response.error() == CopycatError.Type.APPLICATION_ERROR
          || response.error() == CopycatError.Type.UNKNOWN_SESSION_ERROR
          || response.error() == CopycatError.Type.INTERNAL_ERROR) {
          LOGGER.trace("{} - Received {}", id, response);
          future.complete(response);
        } else {
          resendRequest(response.error().createException(), request, sender, connection, future);
        }
      } else if (error instanceof ConnectException || error instanceof TimeoutException || error instanceof TransportException || error instanceof ClosedChannelException) {
        resendRequest(error, request, sender, connection, future);
      } else {
        LOGGER.debug("{} - {} failed! Reason: {}", id, request, error);
        future.completeExceptionally(error);
      }
    }
  }
754647
protected int checkResponse(TCPReadRequestContext rsc) {
        // Parse the proxy server response
        //
        WsByteBuffer[] buffers = rsc.getBuffers();

        // check if the correct response was received
        if (null == buffers) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Could not complete proxy handshake, null buffers");
            }
            return STATUS_ERROR;
        }
        int status = validateProxyResponse(buffers);
        if (STATUS_DONE == status) {
            releaseProxyReadBuffer();
        }
        return status;
    }
94574
static void populateResponse(final ModelNode response, final ServiceController<?> serviceController) {
        response.set(serviceController.getState().toString());
    }
1103402
public static HttpServletResponse getHttpServletResponse(final Response response)
	{
		final WebResponse webResponse = (WebResponse)response;
		final HttpServletResponse httpServletResponse = (HttpServletResponse)webResponse
			.getContainerResponse();
		return httpServletResponse;
	}
2709
protected void sendServerResponse(HttpMessage response) {
        runner.http(action -> action.server(httpServer).send()
                .response(response.getStatusCode())
                .message(response));
    }
958576
protected void sendError( String errText, HttpServletResponse response )
        throws IOException
    {
        sendError( errText, null, response );
    }
1140355
@Override
    public RequestCtx handleResponse(HttpServletRequest request,
                                     HttpServletResponse response)
            throws IOException, ServletException {
        DataResponseWrapper res = (DataResponseWrapper) response;
        byte[] data = res.getData();

        String result = null;
        String body = new String(data);

        if (body.startsWith("<html>")) {
            if (logger.isDebugEnabled()) {
                logger.debug("filtering html");
            }
            result = filterHTML(request, res);
        } else if (body.startsWith("<?xml")) {
            if (logger.isDebugEnabled()) {
                logger.debug("filtering html");
            }
            result = filterXML(request, res);
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("not filtering due to unexpected output: " + body);
            }
            result = body;
        }

        res.setData(result.getBytes());

        return null;
    }
1006016
@Override
    protected void configure() {

        // Run request processor first so give it a high rank
        bind(RequestProcessor.class).to(VertxRequestProcessor.class).ranked(999);
        // Run response processor last so give it a low rank
        bind(ResponseProcessor.class).to(VertxResponseProcessor.class).ranked(-999);
        // Run post response processor last so give it a low rank
        bind(PostResponseProcessor.class).to(VertxPostResponseProcessor.class).ranked(-999);

    }
1231260
@Override
    public RequestCtx handleResponse(HttpServletRequest request,
                                     HttpServletResponse response)
            throws IOException, ServletException {
        ParameterRequestWrapper req = (ParameterRequestWrapper) request;
        DataResponseWrapper res = (DataResponseWrapper) response;

        String body = new String(res.getData());

        if (body.startsWith("<html>")) {
            return null;
        }

        DocumentBuilder docBuilder = null;
        Document doc = null;

        try {
            docBuilder =
                    DocumentBuilderFactory.newInstance().newDocumentBuilder();
            doc = docBuilder.parse(new ByteArrayInputStream(res.getData()));
        } catch (Exception e) {
            throw new ServletException(e);
        }

        Map<String, List<Node>> nodeMap = new HashMap<String, List<Node>>();

        NodeList nodes = doc.getElementsByTagName("rdf:Description");
        for (int x = 0; x < nodes.getLength(); x++) {
            String pid =
                    nodes.item(x).getAttributes().getNamedItem("rdf:about")
                            .getNodeValue();
            if (logger.isDebugEnabled()) {
                logger.debug("RISearchIndexFilter PID: " + pid);
            }

            List<Node> nodeList = nodeMap.get(pid);
            if (nodeList == null) {
                nodeList = new ArrayList<Node>();
                nodeMap.put(pid, nodeList);
            }

            nodeList.add(nodes.item(x));
        }

        if (nodeMap.keySet().size() > 0) {
            Map<String, List<String>> resultMap =
                    new HashMap<String, List<String>>();
            Set<Result> results =
                    evaluatePids(nodeMap.keySet(), resultMap, request, res);

            for (Result r : results) {
                String rid = r.getResource();
                if (rid == null || rid.isEmpty()) {
                    logger.warn("This resource has no resource identifier in the xacml response results!");
                } else {
                    logger.debug("Checking: {}", rid);
                }

                if (r.getStatus().getCode().contains(Status.STATUS_OK)
                        && r.getDecision() != Result.DECISION_PERMIT) {
                    List<String> pids = resultMap.get(rid);
                    for (String pid : pids) {
                        List<Node> nodeList = nodeMap.get(pid);

                        for (Node node : nodeList) {
                            if (node != null && node.getParentNode() != null) {
                                node.getParentNode().removeChild(node);
                                if (logger.isDebugEnabled()) {
                                    logger.debug("Removing: " + pid + " [" + rid
                                            + "]");
                                }
                            } else {
                                logger.warn("Could not locate and/or remove: "
                                        + pid + " [" + rid + "]");
                            }
                        }
                    }
                }
            }
        }

        String[] formats = req.getFormat();
        String format = null;
        if (formats != null
                && formats.length > 0
                && ("RDF/XML".equals(formats[0]) || "N-Triples"
                        .equals(formats[0]))) {
            format = formats[0];
        } else {
            format = "RDF/XML";
        }

        Source src = new DOMSource(doc);
        ByteArrayOutputStream os = null;
        new ByteArrayOutputStream();
        javax.xml.transform.Result dst = null;
        new StreamResult(os);
        if (logger.isDebugEnabled()) {
            os = new ByteArrayOutputStream();
            dst = new StreamResult(os);

            Transformer xFormer = m_transformers.get("RDF/XML");
            try {
                xFormer.transform(src, dst);
            } catch (Exception e) {
                logger.error(e.getMessage());
            }

            logger.debug("RDF/XML:\n" + new String(os.toByteArray()));
        }

        os = new ByteArrayOutputStream();
        dst = new StreamResult(os);
        try {
            if (logger.isDebugEnabled()) {
                logger.debug("Transforming format: " + format);
            }
            Transformer xFormer = m_transformers.get(format);
            xFormer.transform(src, dst);
        } catch (TransformerException te) {
            throw new ServletException("error generating output", te);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("RDF/XML:\n" + new String(os.toByteArray()));
        }

        res.setData(os.toByteArray());
        res.setContentType(m_mimeType.get(format));

        return null;
    }
416242
JsonNode requestResponse(final JsonNode request) {
        try {

            // write request
            String str = request.toString();
            this.stdin.write(str + "\n");
            this.stdin.flush();

            // read response
            JsonNode resp = readNextResponse();

            // throw if this is an error response
            if (resp.has("error")) {
                return processErrorResponse(resp);
            }

            // process synchronous callbacks (which 'interrupt' the response flow).
            if (resp.has("callback")) {
                return processCallbackResponse(resp);
            }

            // null "ok" means undefined result (or void).
            return resp.get("ok");

        } catch (IOException e) {
            throw new JsiiException("Unable to send request to jsii-runtime: " + e.toString(), e);
        }
    }
846915
protected void receiveClientResponse(HttpMessage response) {
        runner.http(action -> {
            HttpClientResponseActionBuilder responseBuilder = action.client(httpClient).receive()
                .response(response.getStatusCode())
                .message(response);

            for (Map.Entry<String, String> headerEntry : pathValidations.entrySet()) {
                responseBuilder.validate(headerEntry.getKey(), headerEntry.getValue());
            }
            pathValidations.clear();
        });
    }
1104247
@PostMapping(path = SamlIdPConstants.ENDPOINT_SAML1_SOAP_ARTIFACT_RESOLUTION)
    protected void handlePostRequest(final HttpServletResponse response,
                                     final HttpServletRequest request) {
        val ctx = decodeSoapRequest(request);
        val artifactMsg = (ArtifactResolve) ctx.getMessage();
        try {
            val issuer = artifactMsg.getIssuer().getValue();
            val service = verifySamlRegisteredService(issuer);
            val adaptor = getSamlMetadataFacadeFor(service, artifactMsg);
            if (adaptor.isEmpty()) {
                throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, "Cannot find metadata linked to " + issuer);
            }
            val facade = adaptor.get();
            verifyAuthenticationContextSignature(ctx, request, artifactMsg, facade);
            val artifactId = artifactMsg.getArtifact().getArtifact();
            val ticketId = getSamlProfileHandlerConfigurationContext().getArtifactTicketFactory().createTicketIdFor(artifactId);
            val ticket = getSamlProfileHandlerConfigurationContext().getTicketRegistry().getTicket(ticketId, SamlArtifactTicket.class);

            val issuerService = getSamlProfileHandlerConfigurationContext().getWebApplicationServiceFactory().createService(issuer);
            val casAssertion = buildCasAssertion(ticket.getTicketGrantingTicket().getAuthentication(),
                issuerService, service,
                CollectionUtils.wrap("artifact", ticket));
            getSamlProfileHandlerConfigurationContext().getResponseBuilder().build(artifactMsg, request, response, casAssertion,
                service, facade, SAMLConstants.SAML2_ARTIFACT_BINDING_URI, ctx);
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
            request.setAttribute(SamlIdPConstants.REQUEST_ATTRIBUTE_ERROR, e.getMessage());
            getSamlProfileHandlerConfigurationContext().getSamlFaultResponseBuilder().build(artifactMsg, request, response,
                null, null, null, SAMLConstants.SAML2_ARTIFACT_BINDING_URI, ctx);
        }
    }
968338
@Override
	public void write(T result, HttpServerRequest request, HttpServerResponse response) {

		if (result != null) {
			response.end(JsonUtils.toJson(result, io.vertx.core.json.Json.mapper));
		}
		else {
			response.end();
		}
	}
1229857
public void onReceivedPesponse(ResponseHeader header, Response response){
        Packet packet = null;
        updateRecv();

        if (header.getXid() == -4) {
            // -4 is the xid for AuthPacket
            if(ErrorCode.AUTHENT_FAILED.equals(header.getErr())) {
                if(getStatus().isAlive()){
                    setStatus(ConnectionStatus.AUTH_FAILED);
                }
            }
                LOGGER.info("Got auth sessionid:0x" + session.id + ", error=" + header.getErr());
            return;
        }

        if (header.getXid() == -1) {
            // -1 means watcher notification
            WatcherEvent event = (WatcherEvent) response;
            if(LOGGER.isTraceEnabled()){
                LOGGER.trace("Got Watcher " + event + " for sessionid 0x" + session.id);
            }
            eventThread.queueWatcherEvent( event );
            return;
        }

        if (header.getXid() == -8) {
            // -8 means server notification
            ServerEvent event = (ServerEvent) response;

            if(response instanceof CloseSessionEvent){
                closeSession();
                return;
            }

            if(LOGGER.isTraceEnabled()){
                LOGGER.trace("Got Server " + event + " for sessionid 0x" + session.id);
            }
            eventThread.queueServerEvent( event );
            return;
        }

        if (header.getXid() == -2) {
            // -2 is the xid for pings
            if(LOGGER.isTraceEnabled()){
                LOGGER.info("Got ping response for sessionid: 0x" + session.id
                        + " after " + (System.currentTimeMillis() - lastPingSentNs) + "ms");
            }

            pingResponse.set(header);
            synchronized(pingResponse){
                pingResponse.notifyAll();
            }
            return;
        }

        synchronized(pendingQueue){
            // the XID out of order, we don't close session here.
            // it doesn't mean the data integrate has problem.
            if(pendingQueue.isEmpty()){
                LOGGER.warn("The request queue is empty, but get packet xid=" + header.getXid());
                // we don't  close session here.
                return;
            }
            int recvXid = header.getXid();
            packet = pendingQueue.remove();

            if (packet.protoHeader.getXid() != recvXid) {
                if(LOGGER.isDebugEnabled()){
                    LOGGER.debug("Packet xid out of order, type=" + packet.protoHeader.getType()
                            + ", queuedXid=" + packet.protoHeader.getXid() + ", xid=" + header.getXid());
                }

                // trim the pendingQueue to the received packet.
                if(packet.protoHeader.getXid() > recvXid){
                    LOGGER.error("Packet xid out of order, drop the received packet, xid=" + header.getXid());
                    pendingQueue.addLast(packet);
                    packet = null;
                } else {
                    while(packet.protoHeader.getXid() != recvXid){
                        LOGGER.error("Packet xid out of order, drop the queued packet, type=" + packet.protoHeader.getType()
                                + ", queuedXid=" + packet.protoHeader.getXid());
                        packet.respHeader.setErr(ErrorCode.CONNECTION_LOSS);
                        finishPacket(packet);

                        if(! pendingQueue.isEmpty()){
                            packet = pendingQueue.remove();
                        } else {
                            return ;
                        }
                    }
                }
            }
        }

        PacketLatency.receivePacket(packet);
        packet.respHeader.setXid(header.getXid());
        packet.respHeader.setErr(header.getErr());
        packet.respHeader.setDxid(header.getDxid());
        if (header.getDxid() > 0) {
            lastDxid = header.getDxid();
        }
        if (ErrorCode.OK.equals(header.getErr())) {
            packet.response = response;
        }

        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Reading reply sessionid:0x"
                    + session.id + ", packet=" + packet);
        }
        finishPacket(packet);

    }
1311822
@Override
    public void handle(Response<ByteSource> rs) throws RestEndpointIOException {
        if (!hasError(rs)) {
            return;
        }

        handleError(rs.getUri(), rs.getHttpMethod(), rs.getStatus(), rs.getReason(), rs.getBody());

    }
537653
public static void bailResponse(HttpContext cx, HttpResponse response) throws IOException, HttpException {
        HttpServerConnection conn = getConnection(cx);
        conn.sendResponseHeader(response);
        conn.sendResponseEntity(response);
        conn.flush();
    }