WebRequest.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Which proxy to use
if (-Not $ProxyServer) {
    $ProxyServer = ''
}
Export-ModuleMember -Variable 'ProxyServer'

# Whether to use the proxy
# Valid values: Proxy, Direct
if (-Not $ProxyPreference) {
    $ProxyPreference = 'Direct'
}
Export-ModuleMember -Variable 'ProxyPreference'

# Whether to use the cache
# Valid values: Cache, ByPass
#if (-Not $global:CachePreference) {
# $global:CachePreference = 'Cache'
#}
if (-Not $CachePreference) {
    $CachePreference = 'ByPass'
}
Export-ModuleMember -Variable 'CachePreference'

# Whether to store the cache for reuse
# Valid values: Dispose, Persist
#if (-not $global:CachePersistence) {
# $global:CachePersistence = 'Dispose'
#}
if (-not $CachePersistence) {
    $CachePersistence = 'Dispose'
}
Export-ModuleMember -Variable 'CachePersistence'

# Item lifetime in seconds
#if (-not $global:CacheLifetime) {
# $global:CacheLifetime = 600
#}
if (-not $CacheLifetime) {
    $CacheLifetime = 600
}
Export-ModuleMember -Variable 'CacheLifetime'

# Cache for request/response objects stored by URL
$script:Cache = @{}

Get-ChildItem -Path "$PSScriptRoot" -Filter '*.ps1' -Recurse | ForEach-Object {
    . "$($_.FullName)"
}