6 public final Map<Object, Object> env;
7 public final Map<Object, Object> resp = new HashMap<>();
8 public String status = "200 OK";
9 public Object body = null;
11 public Request(Map<Object, Object> env) {
15 public String method() {return((String)env.get("REQUEST_METHOD"));}
16 public String remoteaddr() {return((String)env.get("REMOTE_ADDR"));}
17 public String serverport() {return((String)env.get("SERVER_PORT"));}
18 public String servername() {return((String)env.get("SERVER_NAME"));}
19 public String uri() {return((String)env.get("REQUEST_URI"));}
20 public String uriname() {return((String)env.get("SCRIPT_NAME"));}
21 public String filename() {return((String)env.get("SCRIPT_FILENAME"));}
22 public String pathinfo() {return((String)env.get("PATH_INFO"));}
23 public String query() {return((String)env.get("QUERY_STRING"));}
24 public boolean https() {return(env.containsKey("HTTPS"));}
26 public String ihead(String name, String def) {
27 StringBuilder buf = new StringBuilder();
29 for(int i = 0; i < name.length(); i++) {
30 char c = name.charAt(i);
33 else if((c >= 'a') && (c <= 'z'))
34 buf.append((char)(c + ('A' - 'a')));
38 Object ret = env.get(buf.toString());
39 if(ret instanceof String)
44 @SuppressWarnings("unchecked")
45 public Request ohead(String name, Object val, boolean repl) {
46 name = "http." + name;
50 Object cur = resp.get(name);
53 else if(cur instanceof Collection)
54 ((Collection)cur).add(val);
56 resp.put(name, new ArrayList<Object>(Arrays.asList(cur, val)));
61 public Request status(String status) {this.status = status; return(this);}
62 public Request body(Object body) {this.body = body; return(this);}
64 public Map<Object, Object> response() {
65 resp.put("http.status", status);
66 resp.put("jagi.output", body);