Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

46
LINES

< > BotCompany Repo | #1029803 // IWebRequest

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (10732L/59K).

1  
sinterface IWebRequest {
2  
  public S uri();
3  
  public SS params();
4  
  public SS headers();
5  
  public SS files();
6  
  
7  
  default public S clientIP() {
8  
    ret unnull(getClientIPFromHeaders(headers()));
9  
  }
10  
  
11  
  default public S getHeader(S name) { ret mapGet(headers(), name); }
12  
13  
  default public S domain() {
14  
    ret getHeader("host");
15  
  }
16  
17  
  public S cookie();
18  
  
19  
  public bool isHttps();
20  
  
21  
  public bool isPost();
22  
  
23  
  default S protocol() { ret isHttps() ? "https://" : "http://"; }
24  
  
25  
  // mark this request as no-spam (don't count towards spam limit)
26  
  default void noSpam() {}
27  
  
28  
  default S get aka getOpt(S param) { ret mapGet(params(), param); }
29  
  
30  
  default S userAgent() { ret getHeader("user-agent"); }
31  
  
32  
  // proxy another page
33  
  default virtual NanoHTTPD.Response proxy(S url, bool rewriteHost, bool rewritePort) { throw unimplemented(); }
34  
  
35  
  default bool uriIs(S uri) {
36  
    ret eq(uri(), uri);
37  
  }
38  
  
39  
  default bool uriIsIC(S uri) {
40  
    ret eqic(uri(), uri);
41  
  }
42  
  
43  
  default S postData() {
44  
    ret mapGet(files(), "postData");
45  
  }
46  
}

Author comment

Began life as a copy of #1028677

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1029803
Snippet name: IWebRequest
Eternal ID of this version: #1029803/20
Text MD5: 65c8bc1df09731cfc5312c625bc7ebb0
Transpilation MD5: fd5452bd883acb652ab620c0b695e588
Author: stefan
Category: javax / web
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-07-14 23:35:14
Source code size: 1091 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 492 / 899
Version history: 19 change(s)
Referenced in: [show references]