MCPcopy Create free account
hub / github.com/curtcox/JLHTTP / HTTPServer

Class HTTPServer

src/main/java/net/freeutils/httpserver/HTTPServer.java:125–3086  ·  view source on GitHub ↗

The HTTPServer class implements a light-weight HTTP server. This server implements all functionality required by RFC 2616 ("Hypertext Transfer Protocol -- HTTP/1.1"), as well as some of the optional functionality (this is termed "conditionally compliant" in the RFC). In fact, a couple of

Source from the content-addressed store, hash-verified

123 * @since 2008-07-24
124 */
125public class HTTPServer {
126
127 /**
128 * The SimpleDateFormat-compatible formats of dates which must be supported.
129 * Note that all generated date fields must be in the RFC 1123 format only,
130 * while the others are supported by recipients for backwards-compatibility.
131 */
132 public static final String[] DATE_PATTERNS = {
133 "EEE, dd MMM yyyy HH:mm:ss z", // RFC 822, updated by RFC 1123
134 "EEEE, dd-MMM-yy HH:mm:ss z", // RFC 850, obsoleted by RFC 1036
135 "EEE MMM d HH:mm:ss yyyy" // ANSI C's asctime() format
136 };
137
138 /** A GMT (UTC) timezone instance. */
139 protected static final TimeZone GMT = TimeZone.getTimeZone("GMT");
140
141 /** Date format strings. */
142 protected static final char[]
143 DAYS = "Sun Mon Tue Wed Thu Fri Sat".toCharArray(),
144 MONTHS = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".toCharArray();
145
146 /** A convenience array containing the carriage-return and line feed chars. */
147 public static final byte[] CRLF = { 0x0d, 0x0a };
148
149 /** The HTTP status description strings. */
150 protected static final String[] statuses = new String[600];
151
152 static {
153 // initialize status descriptions lookup table
154 Arrays.fill(statuses, "Unknown Status");
155 statuses[100] = "Continue";
156 statuses[200] = "OK";
157 statuses[204] = "No Content";
158 statuses[206] = "Partial Content";
159 statuses[301] = "Moved Permanently";
160 statuses[302] = "Found";
161 statuses[304] = "Not Modified";
162 statuses[307] = "Temporary Redirect";
163 statuses[400] = "Bad Request";
164 statuses[401] = "Unauthorized";
165 statuses[403] = "Forbidden";
166 statuses[404] = "Not Found";
167 statuses[405] = "Method Not Allowed";
168 statuses[408] = "Request Timeout";
169 statuses[412] = "Precondition Failed";
170 statuses[413] = "Request Entity Too Large";
171 statuses[414] = "Request-URI Too Large";
172 statuses[416] = "Requested Range Not Satisfiable";
173 statuses[417] = "Expectation Failed";
174 statuses[500] = "Internal Server Error";
175 statuses[501] = "Not Implemented";
176 statuses[502] = "Bad Gateway";
177 statuses[503] = "Service Unavailable";
178 statuses[504] = "Gateway Time-out";
179 }
180
181 /**
182 * A mapping of path suffixes (e.g. file extensions) to their

Callers

nothing calls this directly

Calls 2

addContentTypeMethod · 0.95
fillMethod · 0.80

Tested by

no test coverage detected