Android Open Source - GenericServer Stream Reply






From Project

Back to project page GenericServer.

License

The source code is released under:

GNU General Public License

If you think the Android project GenericServer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.davecoss.android.genericserver;
/*from ww  w . ja  v  a2 s . co m*/
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.OutputStream;

public class StreamReply extends HTTPReply {

  protected InputStream input = null;  
  
  @Override
  public String get_content_type() {
    return "Content-type: image/x-icon";
  }
  
  @Override
  public void dump_body(PrintWriter output) {
    output.println(this.content);
    output.println("");
    output.flush();
  }

  public void set_input_stream(InputStream input) {
    this.input = input;
  }
  
  @Override
  public void dump_head(OutputStream output) throws java.io.IOException {
    byte[] line_return = "\n".getBytes();
    output.write(this.status.getBytes());output.write(line_return);
    output.write(get_content_type().getBytes());output.write(line_return);
    output.write(line_return);
    output.flush();
    
  }
  
  @Override
  public void write(OutputStream output) throws java.io.IOException {
    
    dump_head(output);
    
    int bytes_read = -1;
    byte[] buffer = new byte[4096];
    while((bytes_read = input.read(buffer)) != -1)
    {
      output.write(buffer, 0, bytes_read);
    }
    output.flush();
  
  }  
}




Java Source Code List

com.davecoss.android.genericserver.BuildInfo.java
com.davecoss.android.genericserver.Console.java
com.davecoss.android.genericserver.EmptyRequest.java
com.davecoss.android.genericserver.FileError.java
com.davecoss.android.genericserver.FileReply.java
com.davecoss.android.genericserver.GenericServer.java
com.davecoss.android.genericserver.HTMLReply.java
com.davecoss.android.genericserver.HTTPError.java
com.davecoss.android.genericserver.HTTPReply.java
com.davecoss.android.genericserver.HTTPRequest.java
com.davecoss.android.genericserver.ImageReply.java
com.davecoss.android.genericserver.InvalidPostData.java
com.davecoss.android.genericserver.InvalidRequestData.java
com.davecoss.android.genericserver.JSONReply.java
com.davecoss.android.genericserver.Module.java
com.davecoss.android.genericserver.Plugin.java
com.davecoss.android.genericserver.SSLServer.java
com.davecoss.android.genericserver.ServerBundle.java
com.davecoss.android.genericserver.ServerHandler.java
com.davecoss.android.genericserver.Standalone.java
com.davecoss.android.genericserver.StreamReply.java
com.davecoss.android.genericserver.UserFile.java