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).

sinterface IWebRequest {
  public S uri();
  public SS params();
  public SS headers();
  public SS files();
  
  default public S clientIP() {
    ret unnull(getClientIPFromHeaders(headers()));
  }
  
  default public S getHeader(S name) { ret mapGet(headers(), name); }

  default public S domain() {
    ret getHeader("host");
  }

  public S cookie();
  
  public bool isHttps();
  
  public bool isPost();
  
  default S protocol() { ret isHttps() ? "https://" : "http://"; }
  
  // mark this request as no-spam (don't count towards spam limit)
  default void noSpam() {}
  
  default S get aka getOpt(S param) { ret mapGet(params(), param); }
  
  default S userAgent() { ret getHeader("user-agent"); }
  
  // proxy another page
  default virtual NanoHTTPD.Response proxy(S url, bool rewriteHost, bool rewritePort) { throw unimplemented(); }
  
  default bool uriIs(S uri) {
    ret eq(uri(), uri);
  }
  
  default bool uriIsIC(S uri) {
    ret eqic(uri(), uri);
  }
  
  default S postData() {
    ret mapGet(files(), "postData");
  }
}

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: 493 / 899
Version history: 19 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)