Annotation of parser3/tests/450-curl.html, revision 1.2
1.1 moko 1: @main[]
2:
3: 1. curl resolve exception:
4: ^try-catch{ ^curl:load[ $.url[https://no-such-domain] ] }
5:
6: #resolve option tests: with the nproc limit set below, the curl threaded resolver
7: #fails to start a getaddrinfo thread, so every request must be resolved
8: #either via explicit resolve entries or via the 'parser' resolve mode
9:
10: $ip[^inet:name2ip[www.parser.ru]]
11: $status:limit-nproc(1)
12:
13: 1.2. parser resolve exception:
14: ^try-catch{ ^curl:load[ $.url[https://no-such-domain] $.resolve[parser] ] }
15:
16: 1.3. detailed resolver error message from CURLOPT_ERRORBUFFER:
17: ^try-catch{ ^curl:load[ $.url[https://no-such-domain] ] }
18:
19: 2. explicit resolve entries populate DNS cache bypassing the resolver:
20: ^load[ $.resolve[ $.[www.parser.ru:80][$ip] ] ]
21:
22: 2.1. port-less entry covers both http and https:
23: ^load[ $.resolve[ $.[www.parser.ru][$ip] ] ]
24: ^load[ $.resolve[ $.[www.parser.ru][$ip] ] ;https://www.parser.ru/_/tests/readme]
25:
26: 3. 'parser' mode resolves synchronously and populates the resolve list automatically:
27: ^load[ $.resolve[parser] ]
28:
29: 4. 'parser' mode can be set outside of 'session' operator:
30: ^curl:options[ $.resolve[parser] ]
31: ^load[]
32:
33: 5. explicit entries have priority over 'parser' mode:
34: ^curl:session{
1.2 ! moko 35: ^curl:options[ $.resolve[ $.[www.parser.ru][195.218.200.197] ] ]
! 36: connects to rol8: ^try-catch-filtered{ ^load[] }
! 37: ^curl:options[ $.resolve[^hash::create[]] ]
! 38: parser resolves to real IP: ^load[]
1.1 moko 39: }
40:
41: 6. revert to 'curl' mode:
42: ^curl:options[ $.resolve[curl] ]
43: ^try-catch{ ^load[] }
44:
45: 7. second load finds the entry added by the first one:
46: ^curl:session{
47: ^curl:options[ $.resolve[parser] ]
48: ^load[]
49: ^curl:options[ $.resolve[curl] ]
50: 7.1. http OK: ^load[]
51: 7.2. https fails (OK): ^try-catch{ ^load[;https://www.parser.ru/_/tests/readme] }
52: }
53:
54: 8. port option is used instead of :port in url:
55: 8.1. ^try-catch-filtered{ ^load[ $.resolve[parser] $.port(8080) ] }
56: ^curl:options[ $.resolve[parser] ]
57: 8.2. ^load[;http://www.parser.ru:80/_/tests/readme]
58: 8.3. ^try-catch-filtered{ ^load[ $.port(8080) ;http://www.parser.ru:80/_/tests/readme] }
59:
60: 9. ^try-catch{ ^curl:options[ $.resolve[dns] ] }
61:
62: 10. empty mode = 'curl' mode:
63: ^curl:options[ $.resolve[] ]
64: ^try-catch{ ^load[] }
65:
66: @load[options;url]
67: ^show[^curl:load[ $options $.url[^if(def $url){$url}{http://www.parser.ru/_/tests/readme}] $.timeout(4) ]]
68:
69: @show[f]
70: status: $f.status, size: $f.size
E-mail: