-
-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathoptions.js
More file actions
151 lines (147 loc) · 4.42 KB
/
options.js
File metadata and controls
151 lines (147 loc) · 4.42 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
const optionKindMap = {
dataCallback: ['READFUNCTION', 'HEADERFUNCTION', 'WRITEFUNCTION'],
progressCallback: ['PROGRESSFUNCTION', 'XFERINFOFUNCTION'],
stringList: [
'CONNECT_TO',
'HTTP200ALIASES',
'HTTPHEADER',
'MAIL_RCPT',
'PROXYHEADER',
'POSTQUOTE',
'PREQUOTE',
'QUOTE',
'RESOLVE',
'TELNETOPTIONS',
],
blob: [
'CAINFO_BLOB',
'ISSUERCERT_BLOB',
'SSLKEY_BLOB',
'SSLCERT_BLOB',
'PROXY_CAINFO_BLOB',
'PROXY_SSLCERT_BLOB',
'PROXY_SSLCERT',
'PROXY_SSLKEY_BLOB',
],
other: [
'CHUNK_BGN_FUNCTION',
'CHUNK_END_FUNCTION',
'DEBUGFUNCTION',
'FNMATCH_FUNCTION',
'HSTSREADFUNCTION',
'HSTSWRITEFUNCTION',
'INTERLEAVEFUNCTION',
'PREREQFUNCTION',
'SEEKFUNCTION',
'SSH_HOSTKEYFUNCTION',
'TRAILERFUNCTION',
'SHARE',
'HTTPPOST',
'STREAM_DEPENDS',
'STREAM_DEPENDS_E',
// enums
'FTP_SSL_CCC',
'FTP_FILEMETHOD',
'GSSAPI_DELEGATION',
'HEADEROPT',
'HTTP_VERSION',
'IPRESOLVE',
'MIMEPOST',
'MIME_OPTIONS',
'NETRC',
'PROTOCOLS',
'PROXY_SSL_OPTIONS',
'PROXYTYPE',
'REDIR_PROTOCOLS',
'RTSP_REQUEST',
'SSH_AUTH_TYPES',
'SSL_OPTIONS',
'SSLVERSION',
'TIMECONDITION',
'USE_SSL',
'WS_OPTIONS',
'HSTS_CTRL',
// @TODO ADD REMAINING OPTIONS WE HAVE ENUM FOR
],
}
const optionKindValueMap = {
dataCallback:
'((this: Easy, data: Buffer, size: number, nmemb: number) => number)',
progressCallback:
'((this: Easy, dltotal: number,dlnow: number,ultotal: number,ulnow: number) => number | CurlProgressFunc)',
stringList: 'string[]',
blob: 'ArrayBuffer | Buffer | string',
/* @TODO Add type definitions, they are on Curl.chunk */
CHUNK_BGN_FUNCTION:
'((this: Easy, fileInfo: FileInfo, remains: number) => CurlChunk)',
/* @TODO Add type definitions, they are on Curl.chunk */
CHUNK_END_FUNCTION: '((this: Easy) => CurlChunk)',
/* @TODO Add type definitions, they are on Curl.info.debug */
DEBUGFUNCTION: '((this: Easy, type: CurlInfoDebug, data: Buffer) => 0)',
/* @TODO Add type definitions, they are on Curl.fnmatchfunc */
FNMATCH_FUNCTION:
'((this: Easy, pattern: string, value: string) => CurlFnMatchFunc)',
HSTSREADFUNCTION:
'((this: Easy, options: { maxHostLengthBytes: number }) => null | CurlHstsCacheEntry | CurlHstsCacheEntry[])',
HSTSWRITEFUNCTION:
'((this: Easy, cacheEntry: CurlHstsCacheEntry, cacheCount: CurlHstsCacheCount) => any)',
INTERLEAVEFUNCTION:
'((this: Easy, data: Buffer, size: number, nmemb: number) => number)',
PREREQFUNCTION:
'((this: Easy, connPrimaryIp: string, connLocalIp: string, connPrimaryPort: number, conLocalPort: number) => CurlPreReqFunc)',
SSH_HOSTKEYFUNCTION:
'((this: Easy, keytype: CurlSshKeyType, key: Buffer) => CurlSshKeyMatch)',
HTTPPOST: 'HttpPostField[]',
TRAILERFUNCTION: '((this: Easy) => string[] | false)',
/* @TODO Add CURL_SEEKFUNC_* type definitions */
SEEKFUNCTION: '((this: Easy, offset: number, origin: number) => number)',
SHARE: 'Share',
MIMEPOST: 'CurlMime',
STREAM_DEPENDS: 'Easy',
STREAM_DEPENDS_E: 'Easy',
// enums
FTP_SSL_CCC: 'CurlFtpSsl',
FTP_FILEMETHOD: 'CurlFtpMethod',
GSSAPI_DELEGATION: 'CurlGssApi',
HEADEROPT: 'CurlHeader',
HTTP_VERSION: 'CurlHttpVersion',
IPRESOLVE: 'CurlIpResolve',
MIME_OPTIONS: 'CurlMimeOpt',
NETRC: 'CurlNetrc',
PROTOCOLS: 'CurlProtocol',
PROXY_SSL_OPTIONS: 'CurlSslOpt',
PROXYTYPE: 'CurlProxy',
REDIR_PROTOCOLS: 'CurlProtocol',
RTSP_REQUEST: 'CurlRtspRequest',
SSH_AUTH_TYPES: 'CurlSshAuth',
SSL_OPTIONS: 'CurlSslOpt',
SSLVERSION: 'CurlSslVersion',
TIMECONDITION: 'CurlTimeCond',
USE_SSL: 'CurlUseSsl',
WS_OPTIONS: 'CurlWsOptions',
HSTS_CTRL: 'CurlHsts',
_: 'string | number | boolean',
}
const optionExtraDescriptionValueMap = Object.fromEntries(
Object.entries({
HSTSREADFUNCTION: [
'',
'You can either return a single `CurlHstsReadCallbackResult` object or an array of `CurlHstsReadCallbackResult` objects.',
'If returning an array, the callback will only be called once per request.',
'If returning a single object, the callback will be called multiple times until `null` is returned.',
],
}).map(([key, value]) => {
return [
key,
`\n*\n${(Array.isArray(value)
? value.join('\n * ')
: `* ${value}`
).trim()}`,
]
}),
)
module.exports = {
optionKindMap,
optionKindValueMap,
optionExtraDescriptionValueMap,
}