public boolean post(HTTPResponse httpRes) {
    HTTPSocket httpSock = getSocket();
    long offset = 0;
    long length = httpRes.getContentLength();
    if (hasContentRange() == true) {
      long firstPos = getContentRangeFirstPosition();
      long lastPos = getContentRangeLastPosition();

      // Thanks for Brent Hills (10/26/04)
      if (lastPos <= 0) lastPos = length - 1;
      if ((firstPos > length) || (lastPos > length))
        return returnResponse(HTTPStatus.INVALID_RANGE);
      httpRes.setContentRange(firstPos, lastPos, length);
      httpRes.setStatusCode(HTTPStatus.PARTIAL_CONTENT);

      offset = firstPos;
      length = lastPos - firstPos + 1;
    }
    return httpSock.post(httpRes, offset, length, isHeadRequest());
    // httpSock.close();
  }
 public boolean returnResponse(int statusCode) {
   HTTPResponse httpRes = new HTTPResponse();
   httpRes.setStatusCode(statusCode);
   httpRes.setContentLength(0);
   return post(httpRes);
 }
  public HTTPResponse post(String host, int port, boolean isKeepAlive) {
    HTTPResponse httpRes = new HTTPResponse();

    setConnection((isKeepAlive == true) ? HTTP.KEEP_ALIVE : HTTP.CLOSE);

    boolean isHeaderRequest = isHeadRequest();

    OutputStream out = null;
    InputStream in = null;

    try {
      if (postSocket == null) postSocket = new Socket(host, port);

      out = postSocket.getOutputStream();
      PrintStream pout = new PrintStream(out);
      pout.print(getHeader());
      pout.print(HTTP.CRLF);

      boolean isChunkedRequest = isChunked();

      String content = getContentString();
      int contentLength = 0;
      if (content != null) contentLength = content.length();

      if (0 < contentLength) {
        if (isChunkedRequest == true) {
          String chunSizeBuf = Long.toString(contentLength);
          pout.print(chunSizeBuf);
          pout.print(HTTP.CRLF);
        }
        pout.print(content);
        if (isChunkedRequest == true) pout.print(HTTP.CRLF);
      }

      if (isChunkedRequest == true) {
        pout.print("0");
        pout.print(HTTP.CRLF);
      }

      pout.flush();

      in = postSocket.getInputStream();
      httpRes.set(in, isHeaderRequest);
    } catch (Exception e) {
      httpRes.setStatusCode(HTTPStatus.INTERNAL_SERVER_ERROR);
    } finally {
      if (isKeepAlive == false) {
        try {
          in.close();
        } catch (Exception e) {
        }
        ;
        if (in != null)
          try {
            out.close();
          } catch (Exception e) {
          }
        ;
        if (out != null)
          try {
            postSocket.close();
          } catch (Exception e) {
          }
        ;
        postSocket = null;
      }
    }

    return httpRes;
  }