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

40
LINES

< > BotCompany Repo | #1031530 // WebRequestFromNanoHTTPD (doesn't compile)

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

Transpiled version (5934L) is out of date.

1  
sclass WebRequestFromNanoHTTPD implements IWebRequest {
2  
  NanoHTTPD.IHTTPSession httpSession;
3  
  S uri, subURI;
4  
  SS params, files;
5  
  S cookie, clientIP;
6  
  Session session;
7  
  bool isHttps, noSpam;
8  
  
9  
  *(NanoHTTPD.IHTTPSession *httpSession, S *uri, SS *params) {}
10  
  
11  
  public S uri() { ret uri; }
12  
  public SS params() { ret params; }
13  
  public SS files() { ret files; }
14  
  
15  
  public SS headers() { ret httpSession.getHeaders(); }
16  
  
17  
  public S cookie() { ret cookie; }
18  
  
19  
  public bool isHttps() { ret isHttps; }
20  
  
21  
  User loggedInUser() {
22  
    ret session == null ? null : session.user();
23  
  }
24  
  
25  
  S googleClientID() {
26  
    S domain = lower(domain());
27  
    File jsonFile = googleClientSecretFileForDomain(domain);
28  
    if (!fileExists(jsonFile)) null;
29  
    
30  
    Map map = decodeJSONMap(loadTextFile(jsonFile));
31  
    map = (Map) map.get("web");
32  
    ret (S) map.get("client_id");
33  
  }
34  
  
35  
  public void noSpam {
36  
    if (noSpam) ret;
37  
    set noSpam;
38  
    print("noSpam count: " + simpleSpamClientDetect2_markNoSpam(clientIP, uri) + " (" + clientIP + "/" + uri + ")");
39  
  }
40  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031530
Snippet name: WebRequestFromNanoHTTPD (doesn't compile)
Eternal ID of this version: #1031530/3
Text MD5: 4514e3d68fc4798db3c4b3d84a328f32
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-18 20:30:18
Source code size: 1098 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 146 / 205
Version history: 2 change(s)
Referenced in: [show references]