Back to project page GenericServer.
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.
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)); } }