@@ -38,10 +38,10 @@ resources are not cleaned up until `Downloader` is garbage collected.
38
38
"""»
39
39
«k:mutable» «k:struct» «t:Downloader»
40
40
multi::«t:Multi»
41
- ca_roots::«t:Union{ String, Nothing}»
42
- easy_hook::«t:Union{ Function, Nothing}»
41
+ ca_roots::«t:Union»{«t: String», «t: Nothing»}
42
+ easy_hook::«t:Union»{«t: Function», «t: Nothing»}
43
43
44
- «f:Downloader»(multi::«t:Multi») = new(multi, get_ca_roots(), EASY_HOOK[])
44
+ «f:Downloader»(multi::«t:Multi») = «k: new» (multi, get_ca_roots(), EASY_HOOK[])
45
45
«k:end»
46
46
«f:Downloader»(; grace::«t:Real»=«c:30») = Downloader(Multi(grace_ms(grace)))
47
47
@@ -63,7 +63,7 @@ resources are not cleaned up until `Downloader` is garbage collected.
63
63
«k:end»
64
64
65
65
«k:const» «v:DOWNLOAD_LOCK» = ReentrantLock()
66
- «k:const» «v:DOWNLOADER» = Ref{ Union{ Downloader, Nothing}}(«b:nothing»)
66
+ «k:const» «v:DOWNLOADER» = «t: Ref»{«t: Union»{«t: Downloader», «t: Nothing» }}(«b:nothing»)
67
67
68
68
«s:"""
69
69
`EASY_HOOK` is a modifable global hook to used as the default `easy_hook` on
@@ -73,7 +73,7 @@ new `Downloader` objects. This supplies a mechanism to set options for the
73
73
It is expected to be function taking two arguments: an `Easy` struct and an
74
74
`info` NamedTuple with names `url`, `method` and `headers`.
75
75
"""»
76
- «k:const» «v:EASY_HOOK» = Ref{ Union{ Function, Nothing}}(«b:nothing»)
76
+ «k:const» «v:EASY_HOOK» = «t: Ref»{«t: Union»{«t: Function», «t: Nothing» }}(«b:nothing»)
77
77
78
78
«s:"""
79
79
struct Response
@@ -100,11 +100,11 @@ not support headers, the headers vector will be empty. HTTP/2 does not include a
100
100
status message, only a status code, so the message will be empty.
101
101
"""»
102
102
«k:struct» «t:Response»
103
- proto :: «t:Union{ String, Nothing}»
103
+ proto :: «t:Union»{«t: String», «t: Nothing»}
104
104
url :: «t:String» «x:# redirected URL»
105
105
status :: «t:Int»
106
106
message :: «t:String»
107
- headers :: «t:Vector{ Pair{ String, String}}»
107
+ headers :: «t:Vector»{«t: Pair»{«t: String»,«t: String»}}
108
108
«k:end»
109
109
110
110
Curl.«f:status_ok»(response::«t:Response») = status_ok(response.proto, response.status)
@@ -246,14 +246,14 @@ Downloads.download("https://httpbingo.julialang.org/delay/30"; downloader)
246
246
"""»
247
247
«k:function» «f:download»(
248
248
url :: «t:AbstractString»,
249
- output :: «t:Union{ ArgWrite, Nothing}» = «b:nothing»;
250
- method :: «t:Union{ AbstractString, Nothing}» = «b:nothing»,
251
- headers :: «t:Union{ AbstractVector, AbstractDict}» = Pair{ String, String}[],
249
+ output :: «t:Union»{«t: ArgWrite», «t: Nothing»} = «b:nothing»;
250
+ method :: «t:Union»{«t: AbstractString», «t: Nothing»} = «b:nothing»,
251
+ headers :: «t:Union»{«t: AbstractVector», «t: AbstractDict»} = «t: Pair»{«t: String»,«t: String» }[],
252
252
timeout :: «t:Real» = «b:Inf»,
253
- progress :: «t:Union{ Function, Nothing}» = «b:nothing»,
253
+ progress :: «t:Union»{«t: Function», «t: Nothing»} = «b:nothing»,
254
254
verbose :: «t:Bool» = «c:false»,
255
- debug :: «t:Union{ Function, Nothing}» = «b:nothing»,
256
- downloader :: «t:Union{ Downloader, Nothing}» = «b:nothing»,
255
+ debug :: «t:Union»{«t: Function», «t: Nothing»} = «b:nothing»,
256
+ downloader :: «t:Union»{«t: Downloader», «t: Nothing»} = «b:nothing»,
257
257
) :: «t:ArgWrite»
258
258
arg_write(output) «k:do» output
259
259
«v:response» = request(
@@ -327,18 +327,18 @@ running request, for example if the user wants to cancel a download.
327
327
"""»
328
328
«k:function» «f:request»(
329
329
url :: «t:AbstractString»;
330
- input :: «t:Union{ ArgRead, Nothing}» = «b:nothing»,
331
- output :: «t:Union{ ArgWrite, Nothing}» = «b:nothing»,
332
- method :: «t:Union{ AbstractString, Nothing}» = «b:nothing»,
333
- headers :: «t:Union{ AbstractVector, AbstractDict}» = Pair{ String, String}[],
330
+ input :: «t:Union»{«t: ArgRead», «t: Nothing»} = «b:nothing»,
331
+ output :: «t:Union»{«t: ArgWrite», «t: Nothing»} = «b:nothing»,
332
+ method :: «t:Union»{«t: AbstractString», «t: Nothing»} = «b:nothing»,
333
+ headers :: «t:Union»{«t: AbstractVector», «t: AbstractDict»} = «t: Pair»{«t: String»,«t: String» }[],
334
334
timeout :: «t:Real» = «b:Inf»,
335
- progress :: «t:Union{ Function, Nothing}» = «b:nothing»,
335
+ progress :: «t:Union»{«t: Function», «t: Nothing»} = «b:nothing»,
336
336
verbose :: «t:Bool» = «c:false»,
337
- debug :: «t:Union{ Function, Nothing}» = «b:nothing»,
337
+ debug :: «t:Union»{«t: Function», «t: Nothing»} = «b:nothing»,
338
338
throw :: «t:Bool» = «c:true»,
339
- downloader :: «t:Union{ Downloader, Nothing}» = «b:nothing»,
340
- interrupt :: «t:Union{ Nothing, Base.Event}» = «b:nothing»,
341
- ) :: «t:Union{ Response, RequestError}»
339
+ downloader :: «t:Union»{«t: Downloader», «t: Nothing»} = «b:nothing»,
340
+ interrupt :: «t:Union»{«t: Nothing» , Base.Event} = «b:nothing»,
341
+ ) :: «t:Union»{«t: Response», «t: RequestError»}
342
342
«k:if» downloader === «b:nothing»
343
343
lock(DOWNLOAD_LOCK) «k:do»
344
344
«v:downloader» = DOWNLOADER[]
@@ -396,7 +396,7 @@ running request, for example if the user wants to cancel a download.
396
396
397
397
«x:# do the request»
398
398
add_handle(downloader.multi, easy)
399
- «v:interrupted» = Threads.Atomic{Bool}(«c:false»)
399
+ «v:interrupted» = Threads.Atomic{«t: Bool» }(«c:false»)
400
400
«k:if» interrupt !== «b:nothing»
401
401
«v:interrupt_task» = «:julia-ts-macro-face:@async» «k:begin»
402
402
«x:# wait for the interrupt event»
@@ -459,8 +459,8 @@ running request, for example if the user wants to cancel a download.
459
459
«x:## helper functions ##»
460
460
461
461
«k:function» «f:p_func»(progress::«t:Function», input::«t:ArgRead», output::«t:ArgWrite»)
462
- hasmethod(progress, NTuple{«c:4»,Int}) && «k:return» progress
463
- hasmethod(progress, NTuple{«c:2»,Int}) ||
462
+ hasmethod(progress, «t: NTuple» {«c:4»,«t: Int» }) && «k:return» progress
463
+ hasmethod(progress, «t: NTuple» {«c:2»,«t: Int» }) ||
464
464
throw(ArgumentError(«s:"invalid progress callback"»))
465
465
466
466
input === devnull && output !== devnull &&
@@ -474,11 +474,11 @@ running request, for example if the user wants to cancel a download.
474
474
«f:p_func»(progress::«t:Nothing», input::«t:ArgRead», output::«t:ArgWrite») = «b:nothing»
475
475
476
476
«f:arg_read_size»(path::«t:AbstractString») = filesize(path)
477
- «f:arg_read_size»(io::«t:Base. GenericIOBuffer») = bytesavailable(io)
477
+ «f:arg_read_size»(io::Base. «t:GenericIOBuffer») = bytesavailable(io)
478
478
«f:arg_read_size»(::«t:Base.DevNull») = «c:0»
479
479
«f:arg_read_size»(::«t:Any») = «b:nothing»
480
480
481
- «k:function» «f:content_length»(headers::«t:Union{ AbstractVector, AbstractDict}» )
481
+ «k:function» «f:content_length»(headers::«t:Union»{«t: AbstractVector», «t: AbstractDict»} )
482
482
«k:for» (key, value) «k:in» headers
483
483
«k:if» lowercase(key) == «s:"content-length"» && isa(value, AbstractString)
484
484
«k:return» tryparse(Int, value)
@@ -497,7 +497,7 @@ running request, for example if the user wants to cancel a download.
497
497
Set the default `Downloader`. If no argument is provided, resets the default downloader so that a fresh one is created the next time the default downloader is needed.
498
498
"""»
499
499
«k:function» «f:default_downloader!»(
500
- downloader :: «t:Union{ Downloader, Nothing}» = «b:nothing»
500
+ downloader :: «t:Union»{«t: Downloader», «t: Nothing»} = «b:nothing»
501
501
)
502
502
lock(DOWNLOAD_LOCK) «k:do»
503
503
DOWNLOADER[] = downloader
@@ -510,8 +510,8 @@ Set the default `Downloader`. If no argument is provided, resets the default dow
510
510
«v:d» = Downloader()
511
511
«v:f» = mktemp()[«c:1»]
512
512
download(«s:"file://"» * f; «:julia-ts-quoted-symbol-face:downloader»=d)
513
- precompile(Tuple{typeof(Downloads.download), String, String})
514
- precompile(Tuple{typeof(Downloads.Curl.status_2xx_ok), Int64})
513
+ precompile(«t: Tuple» {typeof(Downloads.download), «t: String», «t: String» })
514
+ precompile(«t: Tuple» {typeof(Downloads.Curl.status_2xx_ok), «t: Int64» })
515
515
«k:end»
516
516
517
517
«k:end» «x:# module»
0 commit comments