private void sendRequestCheckResponse(EmbeddedChannel channel, HttpRequest httpRequest, String uri,
      HttpHeaders headers, boolean testErrorCase, boolean chunkedResponse, boolean sslUsed) throws Exception {
    channel.writeInbound(httpRequest);
    if (uri.equals(EchoMethodHandler.DISCONNECT_URI)) {
      channel.disconnect();
    } else {
      channel.writeInbound(new DefaultLastHttpContent());
    }
    String lastLogEntry = publicAccessLogger.getLastPublicAccessLogEntry();
    // verify remote host, http method and uri
    String subString = testErrorCase ? "Error" : "Info" + ":embedded" + " " + httpRequest.method() + " " + uri;
    Assert.assertTrue("Public Access log entry doesn't have expected remote host/method/uri ",
        lastLogEntry.startsWith(subString));
    // verify SSL-related info
    subString = "SSL ([used=" + sslUsed + "]";
    if (sslUsed) {
      subString += ", [principal=" + PEER_CERT.getSubjectX500Principal() + "]";
      Collection<List<?>> sans = PEER_CERT.getSubjectAlternativeNames();
      if (sans != null && !sans.isEmpty()) {
        sans = sans.stream().filter(p -> (Integer) p.get(0) != 2).collect(Collectors.toList());
      }
      subString += ", [san=" + sans + "]";
    }
    subString += ")";
    Assert.assertTrue("Public Access log entry doesn't have SSL info set correctly", lastLogEntry.contains(subString));
    // verify request headers
    verifyPublicAccessLogEntryForRequestHeaders(lastLogEntry, headers, httpRequest.method(), true);

    // verify response
    subString = "Response (";
    for (String responseHeader : RESPONSE_HEADERS.split(",")) {
      if (headers.contains(responseHeader)) {
        subString += "[" + responseHeader + "=" + headers.get(responseHeader) + "] ";
      }
    }
    subString += "[isChunked=" + chunkedResponse + "]), status=" + HttpResponseStatus.OK.code();

    if (!testErrorCase) {
      Assert.assertTrue("Public Access log entry doesn't have response set correctly",
          lastLogEntry.contains(subString));
    } else {
      Assert.assertTrue("Public Access log entry doesn't have error set correctly ",
          lastLogEntry.contains(": Channel closed while request in progress."));
    }
  }
Sends the provided {@code httpRequest} and verifies that the response is as expected.
@param channel the {@link EmbeddedChannel} to send the request over.
@param httpRequest the {@link HttpRequest} that has to be sent
@param uri, Uri to be used for the request
@param headers {@link HttpHeaders} that is set in the request to be used for verification purposes
@param testErrorCase true if error case has to be tested, false otherwise
@param sslUsed true if SSL was used for this request.
ambry-rest/src/test/java/com/github/ambry/rest/PublicAccessLogHandlerTest.java