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 ihead(String name, String def) {
16 StringBuilder buf = new StringBuilder();
18 for(int i = 0; i < name.length(); i++) {
19 char c = name.charAt(i);
22 else if((c >= 'a') && (c <= 'z'))
23 buf.append((char)(c + ('A' - 'a')));
27 Object ret = env.get(buf.toString());
28 if(ret instanceof String)
33 @SuppressWarnings("unchecked")
34 public Request ohead(String name, Object val, boolean repl) {
35 name = "http." + name;
39 Object cur = resp.get(name);
42 else if(cur instanceof Collection)
43 ((Collection)cur).add(val);
45 resp.put(name, new ArrayList<Object>(Arrays.asList(cur, val)));
50 public Request status(String status) {this.status = status; return(this);}
51 public Request body(Object body) {this.body = body; return(this);}
53 public Map<Object, Object> response() {
54 resp.put("http.status", status);
55 resp.put("jagi.output", body);