Android Open Source - GenericServer H T T P 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;
//  w w  w.  jav  a  2s.  c  o m
import java.io.IOException;
import java.io.PrintWriter;
import java.io.OutputStream;


public class HTTPReply {
  
  // Status messages
  public static final String STATUS_OK = "HTTP/1.1 200 Ok";
  public static final String STATUS_FORBIDDEN = "HTTP/1.1 403 Forbidden";
  public static final String STATUS_NOT_FOUND = "HTTP/1.1 403 Not Found";
  public static final String STATUS_ERROR = "HTTP/1.1 500 Server Error";
  
  protected String content;
  protected String title;
  protected String status;
  
  public HTTPReply() {
    this.content = "";
    this.title = "";
    this.status = STATUS_OK;
  }

  public HTTPReply(String content) {
    this.content = content;
    this.title = content;
    this.status = STATUS_OK;
  }
  
  public HTTPReply(String title, String content)
  {
    this.content = content;
    this.title = title;
    this.status = STATUS_OK;
  }
  
  public HTTPReply(String title, String content, String status)
  {
    this.content = content;
    this.title = title;
    this.status = status;
  }
  
  public String get_content()
  {
    return this.content;
  }
  
  public HTTPReply set_content(String content) {
    this.content = content;
    return this;
  }
  
  public String get_title()
  {
    return this.title;
  }
  
  public HTTPReply set_title(String title) {
    this.title = title;
    return this;
  }
  
  public String get_status()
  {
    return this.status;
  }
  
  public HTTPReply set_status(String status) {
    this.status = status;
    return this;
  }
  
  public String get_content_type() {
    return "Content-type: text/plain";
  }
  
  public void dump_head(PrintWriter output) {
    output.println(this.status);
    output.println(get_content_type());
    output.println("");
    output.flush();
  }
  
  public void dump_head(OutputStream outstream) throws IOException {
    dump_head(new PrintWriter(outstream));
  }
  
  public void dump_body(PrintWriter output) {
    output.println(this.content);
    output.println("");
    output.flush();
  }
  
  public void dump_body(OutputStream outstream) {
    dump_body(new PrintWriter(outstream));
  }
  
  public void dump(PrintWriter output)
  {
    dump_head(output);
    dump_body(output);
  }

  public void write(OutputStream output) throws IOException {
    dump(new PrintWriter(output));
  }
  
}




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