@@ -3,15 +3,16 @@ Curl Wrapper
3
3
4
4
all curl methods accepts
5
5
6
- url = "The url to make the request to.", (string)
7
- query = "url query, append after the url", (table)
8
- body = "The request body" (string/filepath/table)
9
- auth = "Basic request auth, 'user:pass', or {"user", "pass"}" (string/array)
10
- form = "request form" (table)
11
- raw = "any additonal curl args, it must be an array/list." (array)
12
- dry_run = "whether to return the args to be ran through curl." (boolean)
13
- output = "where to download something." (filepath)
14
- timeout = "request timeout in mseconds" (number)
6
+ url = "The url to make the request to.", (string)
7
+ query = "url query, append after the url", (table)
8
+ body = "The request body" (string/filepath/table)
9
+ auth = "Basic request auth, 'user:pass', or {"user", "pass"}" (string/array)
10
+ form = "request form" (table)
11
+ raw = "any additonal curl args, it must be an array/list." (array)
12
+ dry_run = "whether to return the args to be ran through curl." (boolean)
13
+ output = "where to download something." (filepath)
14
+ timeout = "request timeout in mseconds" (number)
15
+ http_version = "HTTP version to use: 'HTTP/0.9', 'HTTP/1.0', 'HTTP/1.1', 'HTTP/2', or 'HTTP/3'" (string)
15
16
16
17
and returns table:
17
18
@@ -179,6 +180,19 @@ parse.accept_header = function(s)
179
180
return { " -H" , " Accept: " .. s }
180
181
end
181
182
183
+ parse .http_version = function (s )
184
+ if not s then
185
+ return
186
+ end
187
+ if s == " HTTP/0.9" or s == " HTTP/1.0" or s == " HTTP/1.1" or s == " HTTP/2" or s == " HTTP/3" then
188
+ s = s :lower ()
189
+ s = s :gsub (" /" , " " )
190
+ return { " --" .. s }
191
+ else
192
+ error " Unknown HTTP version."
193
+ end
194
+ end
195
+
182
196
-- Parse Request -------------------------------------------
183
197
---- --------------------------------------------------------
184
198
parse .request = function (opts )
@@ -215,6 +229,7 @@ parse.request = function(opts)
215
229
append (parse .form (opts .form ))
216
230
append (parse .file (opts .in_file ))
217
231
append (parse .auth (opts .auth ))
232
+ append (parse .http_version (opts .http_version ))
218
233
append (opts .raw )
219
234
if opts .output then
220
235
table.insert (result , { " -o" , opts .output })
0 commit comments