public Integer handleResponse(ESXX esxx, Context cx, Response response) throws Exception {
    // Output HTTP headers
    final PrintWriter out = new PrintWriter(createWriter(outStream, "US-ASCII"));

    out.println("Status: " + response.getStatus());
    out.println("Content-Type: " + response.getContentType(true));

    response.enumerateHeaders(
        new Response.HeaderEnumerator() {
          public void header(String name, String value) {
            out.println(name + ": " + value);
          }
        });

    out.println();
    out.flush();

    response.writeResult(esxx, cx, outStream);

    getErrorWriter().flush();
    getDebugWriter().flush();
    outStream.flush();

    return 0;
  }
  public Integer handleResponse(Response response) throws Exception {
    try {
      int status = response.getStatus();

      sres.setStatus(status);
      sres.setContentType(response.getContentType(true));

      response.enumerateHeaders(
          new Response.HeaderEnumerator() {
            public void header(String name, String value) {
              sres.addHeader(name, value);
            }
          });

      if ((status >= 100 && status <= 199) || status == 204 || status == 205 || status == 304) {
        // No body
      } else {
        if (response.isBuffered()) {
          // Output Content-Length header, if size is known
          setContentLength(sres, response.getContentLength());
        }

        // Output body
        response.writeResult(sres.getOutputStream());
      }

      return 0;
    } catch (IOException ex) {
      // If we fail to send response, it's probably just because
      // nobody is listening anyway.
      return 20;
    } finally {
      sres.flushBuffer();
    }
  }