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

54
LINES

< > BotCompany Repo | #1016488 // URL Checker [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (14736L/101K).

1  
!7
2  
3  
//set flag InputChooser_verbose.
4  
5  
sclass URLChecker extends DynTextArea {
6  
  InputChooser inputChooser = new(this);
7  
  S url;
8  
  bool mayQuery;
9  
  Map<S, L<S>> headers;
10  
  long size;
11  
  PersistableThrowable loadError;
12  
  
13  
  JComponent visualize() {
14  
    ret northAndCenter(wrap(inputChooser), super.visualize());
15  
  }
16  
  
17  
  void update {
18  
    temp enter();
19  
    if (!inputChooser.update()) ret;
20  
    
21  
    fS input = inputChooser.input();
22  
    if (!isURL(input)) ret;
23  
    if (!setField(url := input)) ret;
24  
    actualUpdate();
25  
  }
26  
  
27  
  void actualUpdate {
28  
    temp enter();
29  
    setFields(mayQuery := false, headers := null, loadError := null);
30  
    clearText();
31  
    printToText("URL found: " + url);
32  
    setField(mayQuery := mayQueryURLByHead(url));
33  
    printToText("May query: " + yn(mayQuery));
34  
    if (!mayQuery) ret;
35  
    // TODO: also get content type
36  
    try {
37  
      setField(headers := getURLHeadersByHEAD(url));
38  
    } catch e {
39  
      printShortException(e);
40  
      setField(loadError := persistableThrowable(e));
41  
    }
42  
    if (headers != null) {
43  
      printToText("Headers:");
44  
      for (S key, L<S> values : headers) {
45  
        for (S value : values)
46  
          printToText(key + " = " + value);
47  
      }
48  
    }
49  
  }
50  
  
51  
  bool mayQueryURLByHead(S url) {
52  
    true;
53  
  }
54  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1016488
Snippet name: URL Checker [Dyn Module]
Eternal ID of this version: #1016488/9
Text MD5: 5bea58adecdc9ffe6db4f2a23c1c1028
Transpilation MD5: 2dc63cfdc13963b43794599984448121
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-21 23:33:53
Source code size: 1311 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 320 / 1880
Version history: 8 change(s)
Referenced in: [show references]