@@ -3,15 +3,16 @@ Curl Wrapper
33
44all curl methods accepts
55
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)
1516
1617and returns table:
1718
@@ -179,6 +180,19 @@ parse.accept_header = function(s)
179180 return { " -H" , " Accept: " .. s }
180181end
181182
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+
182196-- Parse Request -------------------------------------------
183197---- --------------------------------------------------------
184198parse .request = function (opts )
@@ -215,6 +229,7 @@ parse.request = function(opts)
215229 append (parse .form (opts .form ))
216230 append (parse .file (opts .in_file ))
217231 append (parse .auth (opts .auth ))
232+ append (parse .http_version (opts .http_version ))
218233 append (opts .raw )
219234 if opts .output then
220235 table.insert (result , { " -o" , opts .output })
0 commit comments