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.

Clone this repository (size: 135.2 KB): HTTPS / SSH
$ hg clone http://hg.openstatic.org/placebohttp
commit 33: 76efabe6b8ff
parent 32: 1e684995023a
branch: default
fixed path parsing alot
xitiomet
4 months ago

Changed (Δ618 bytes):

raw changeset »

.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 .hgignore:

Binary file has changed or diff was empty.

Up to file-list README:

Binary file has changed or diff was empty.

Up to file-list compile.cmd:

Binary file has changed or diff was empty.

Up to file-list manifest.mf:

Binary file has changed or diff was empty.

Up to file-list src/org/json/CDL.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/Cookie.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/CookieList.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/HTTP.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/HTTPTokener.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/JSONArray.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/JSONException.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/JSONML.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/JSONObject.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/JSONString.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/JSONStringer.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/JSONTokener.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/JSONWriter.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/Test.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/XML.java:

Binary file has changed or diff was empty.

Up to file-list src/org/json/XMLTokener.java:

Binary file has changed or diff was empty.

Up to file-list src/org/openstatic/placebo/ControlPanel.java:

Binary file has changed or diff was empty.

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 = path_inside_file.toString();
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 = new_path.toString();
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:

Binary file has changed or diff was empty.

Up to file-list src/org/openstatic/util/JTextAreaOutputStream.java:

Binary file has changed or diff was empty.

Up to file-list www/idx2.gif:

Binary file has changed or diff was empty.

Up to file-list www/placebo.png:

Binary file has changed or diff was empty.