xitiomet / placebohttp (http://openstatic.org/)
Embeded Http server for gcj/java applications. PlaceboHttp uses an automatic session management system, Treating each session as a HttpRequest queue.
| commit 33: | 76efabe6b8ff |
| parent 32: | 1e684995023a |
| branch: | default |
Changed (Δ618 bytes):
.hgignore (binary file changed)
README (binary file changed)
compile.cmd (binary file changed)
manifest.mf (binary file changed)
src/org/json/CDL.java (binary file changed)
src/org/json/Cookie.java (binary file changed)
src/org/json/CookieList.java (binary file changed)
src/org/json/HTTP.java (binary file changed)
src/org/json/HTTPTokener.java (binary file changed)
src/org/json/JSONArray.java (binary file changed)
src/org/json/JSONException.java (binary file changed)
src/org/json/JSONML.java (binary file changed)
src/org/json/JSONObject.java (binary file changed)
src/org/json/JSONString.java (binary file changed)
src/org/json/JSONStringer.java (binary file changed)
src/org/json/JSONTokener.java (binary file changed)
src/org/json/JSONWriter.java (binary file changed)
src/org/json/Test.java (binary file changed)
src/org/json/XML.java (binary file changed)
src/org/json/XMLTokener.java (binary file changed)
src/org/openstatic/placebo/ControlPanel.java (binary file changed)
src/org/openstatic/placebo/CoreServer.java (26 lines added, 9 lines removed)
src/org/openstatic/util/JSONUtil.java (binary file changed)
src/org/openstatic/util/JTextAreaOutputStream.java (binary file changed)
www/idx2.gif (binary file changed)
www/placebo.png (binary file changed)
Up to file-list src/org/json/CDL.java:
Up to file-list src/org/json/Cookie.java:
Up to file-list src/org/json/CookieList.java:
Up to file-list src/org/json/HTTP.java:
Up to file-list src/org/json/HTTPTokener.java:
Up to file-list src/org/json/JSONArray.java:
Up to file-list src/org/json/JSONException.java:
Up to file-list src/org/json/JSONML.java:
Up to file-list src/org/json/JSONObject.java:
Up to file-list src/org/json/JSONString.java:
Up to file-list src/org/json/JSONStringer.java:
Up to file-list src/org/json/JSONTokener.java:
Up to file-list src/org/json/JSONWriter.java:
Up to file-list src/org/json/Test.java:
Up to file-list src/org/json/XML.java:
Up to file-list src/org/json/XMLTokener.java:
Up to file-list src/org/openstatic/placebo/ControlPanel.java:
Up to file-list src/org/openstatic/placebo/CoreServer.java:
| … | … | @@ -47,6 +47,20 @@ public class CoreServer extends Thread |
47 |
47 |
addPlugin(key, plugin_list.get(key)); |
48 |
48 |
} |
49 |
49 |
} |
50 |
||
51 |
private String resolve_index(String path) |
|
52 |
{ |
|
53 |
String new_path = path; |
|
54 |
if (path.endsWith("/")) |
|
55 |
{ |
|
56 |
new_path = path + "index.html"; |
|
57 |
} |
|
58 |
if (path.endsWith(".")) |
|
59 |
{ |
|
60 |
new_path = path + "/index.html"; |
|
61 |
} |
|
62 |
return new_path; |
|
63 |
} |
|
50 |
64 |
|
51 |
65 |
public void addPlugin(String path, String class_name) |
52 |
66 |
{ |
| … | … | @@ -158,13 +172,7 @@ public class CoreServer extends Thread |
158 |
172 |
// create new response object |
159 |
173 |
HttpResponse response = new HttpResponse(); |
160 |
174 |
String path = web_root + request.getPath(); |
161 |
||
162 |
// add index to the path if needed |
|
163 |
if (path.endsWith("/")) |
|
164 |
{ |
|
165 |
path += "index.html"; |
|
166 |
} |
|
167 |
||
175 |
server.logln("Possible Resource [" + path + "]"); |
|
168 |
176 |
// this wacky thing is for finding out if we are inside a zip |
169 |
177 |
// and retrieving the proper content. |
170 |
178 |
StringTokenizer path_tokens = new StringTokenizer(path, "/"); |
| … | … | @@ -202,9 +210,18 @@ public class CoreServer extends Thread |
202 |
210 |
// are we done traveling the path |
203 |
211 |
if (!path_tokens.hasMoreTokens()) |
204 |
212 |
{ |
213 |
// if the original path had a trailing slash, so should the final |
|
214 |
if (path.endsWith("/")) |
|
215 |
{ |
|
216 |
if (in_file) |
|
217 |
{ |
|
218 |
path_inside_file.append("/"); |
|
219 |
} |
|
220 |
new_path.append("/"); |
|
221 |
} |
|
205 |
222 |
try |
206 |
223 |
{ |
207 |
String file_internal_path = |
|
224 |
String file_internal_path = resolve_index(path_inside_file.toString()); |
|
208 |
225 |
if (in_file && !"".equals(file_internal_path)) |
209 |
226 |
{ // we are in a path that requires special processing |
210 |
227 |
|
| … | … | @@ -247,7 +264,7 @@ public class CoreServer extends Thread |
247 |
264 |
} |
248 |
265 |
|
249 |
266 |
} else { // we just have a normal file to serve |
250 |
String file_final_path = |
|
267 |
String file_final_path = resolve_index(new_path.toString()); |
|
251 |
268 |
server.logln("File: " + file_final_path); |
252 |
269 |
response.setData(new File(file_final_path)); |
253 |
270 |
} |
Up to file-list src/org/openstatic/util/JSONUtil.java:
Up to file-list src/org/openstatic/util/JTextAreaOutputStream.java:
Up to file-list www/placebo.png:
