Examples of HttpInputStream


Examples of sunlabs.brazil.util.http.HttpInputStream

    {
  this.server = server;
  this.sock = sock;

  try {
      in = new HttpInputStream(
        new BufferedInputStream(sock.getInputStream()));
      out = new HttpOutputStream(
        new BufferedOutputStream(sock.getOutputStream()));
  } catch (IOException e) {
      /*
 
View Full Code Here

Examples of sunlabs.brazil.util.http.HttpInputStream

     */
    public void
    sendResponse(InputStream in, int length, String type, int code)
  throws IOException
    {
  HttpInputStream hin = new HttpInputStream(in);

  byte[] buf = new byte[server.bufsize];
     
  if (length >= 0) {
      sendHeaders(code, type, length);
      if (!method.equals("HEAD")) {
         if (hin.copyTo(out, length, buf) != length) {
       keepAlive = false;
         }
      }
  } else if (version <= 10) {
      keepAlive = false;
      sendHeaders(code, type, -1);
      if (!method.equals("HEAD")) {
         hin.copyTo(out, -1, buf);
      }
  } else {
      if (method.equals("HEAD")) {
          sendHeaders(code, type, -1);
    return;
      }

      addHeader("Transfer-Encoding", "chunked");
      sendHeaders(code, type, -1);

      while (true) {
    int count = hin.read(buf);
    if (count < 0) {
        out.writeBytes("0\r\n\r\n");
        break;
    }
    out.writeBytes(Integer.toHexString(count) + "\r\n");
View Full Code Here

Examples of sunlabs.brazil.util.http.HttpInputStream

  }

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  String result = null;
  try {
      HttpInputStream hin = new HttpInputStream(
        ResourceHandler.getResourceStream(
      hr.request.props, hr.prefix, src));
      hin.copyTo(baos);
      hin.close();
  } catch (IOException e) {
      debug(hr, "Bad import file: " + e);
      return;
  }
  if (enc != null) {
View Full Code Here

Examples of sunlabs.brazil.util.http.HttpInputStream

  try {
      Socket s = new Socket(host, port);
      out = new Request.HttpOutputStream(
      s.getOutputStream());
      SocketReader reader = new SocketReader(queueName,
        new HttpInputStream( s.getInputStream()));
      reader.start();
      String login = "Action: login\r\nUserName: " + user + "\r\n" +
    "Secret: " + pass + "\r\n\r\n";
      out.writeBytes(login);
      out.flush();
View Full Code Here

Examples of sunlabs.brazil.util.http.HttpInputStream

      if (!file.isDirectory()) {
    file = new File(file.getParent());
      }
      file = new File(file, name);
  }
  HttpInputStream hin = new HttpInputStream(in);
  try {
      FileOutputStream out = new FileOutputStream(file);
      hin.copyTo(out);
      log(hr, Server.LOG_DIAGNOSTIC, "wrote file: " + file);
  } catch (IOException e) {
      log(hr, Server.LOG_LOG, "Can't write file: " + e.getMessage());
  }
    }
View Full Code Here

Examples of sunlabs.brazil.util.http.HttpInputStream

    getResourceString(Properties props, String prefix, String file)
  throws IOException
    {
  InputStream in = getResourceStream(props, prefix, file);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  new HttpInputStream(in).copyTo(out);
        in.close();
  return out.toString();
    }
View Full Code Here

Examples of sunlabs.brazil.util.http.HttpInputStream

    getResourceBytes(Properties props, String prefix, String file)
  throws IOException
    {
  InputStream in = getResourceStream(props, prefix, file);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  new HttpInputStream(in).copyTo(out);
        in.close();
  return out.toByteArray();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.