Libraryless. Click here for Pure Java version (12270L/74K).
1 | sclass WebRequest is IWebRequest { |
2 | NanoHTTPD.IHTTPSession httpSession; |
3 | S uri, subURI; |
4 | SS params, files; |
5 | S cookie, clientIP; |
6 | bool isHttps, noSpam; |
7 | |
8 | *(NanoHTTPD.IHTTPSession *httpSession, S *uri, SS *params) { |
9 | files = httpSession.getFiles(); |
10 | clientIP = getClientIPFromHeaders(httpSession.getHeaders()); |
11 | } |
12 | |
13 | public S uri() { ret uri; } |
14 | public SS params() { ret params; } |
15 | public SS files() { ret files; } |
16 | |
17 | public SS headers() { ret httpSession.getHeaders(); } |
18 | |
19 | public S cookie() { ret cookie; } |
20 | |
21 | public bool isHttps() { ret isHttps; } |
22 | |
23 | public bool isPost() { ret httpSession.getMethod() == NanoHTTPD.Method.POST; } |
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 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035555 |
Snippet name: | WebRequest |
Eternal ID of this version: | #1035555/3 |
Text MD5: | 18a602e11812f7ff961e91f95b87bd62 |
Transpilation MD5: | e28d5d98c1ea5a605f3ea8a368d3aa56 |
Author: | stefan |
Category: | javax / http |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-06-16 19:16:36 |
Source code size: | 1169 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 147 / 1446 |
Version history: | 2 change(s) |
Referenced in: | [show references] |