Libraryless. Click here for Pure Java version (4392L/27K).
sclass PostRequest { S method = "POST"; S url; MapSO params = new LinkedHashMap; SS headers = new LinkedHashMap; *() {} *(S *url, O... _) { params = paramsToMap(_); } S perform() { if (eq(method, "POST")) ret doPostWithHeaders(url, headers, params); else if (eq(method, "GET")) ret loadPageWithHeaders(appendQueryToURL(url, params), headers); else fail("Unknown method: " + method); } selfType set(S param, O value) { params.put(param, value); this; } selfType switchToGet() { method = "GET"; this; } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030464 |
Snippet name: | PostRequest |
Eternal ID of this version: | #1030464/10 |
Text MD5: | 3437b7b94b114ff5c90869e578a684ee |
Transpilation MD5: | 10398d172f647884f014f8ddd1c44d16 |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-12-22 23:29:25 |
Source code size: | 604 bytes / 27 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 247 / 514 |
Version history: | 9 change(s) |
Referenced in: | [show references] |