File tree Expand file tree Collapse file tree 3 files changed +33
-5
lines changed
Expand file tree Collapse file tree 3 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ rest.run = function(verbose)
2222 Opts = {
2323 method = result .method :lower (),
2424 url = result .url ,
25+ -- plenary.curl can't set http protocol version
26+ -- http_version = result.http_version,
2527 headers = result .headers ,
2628 raw = config .get (" skip_ssl_verification" ) and { " -k" } or nil ,
2729 body = result .body ,
@@ -44,7 +46,7 @@ rest.run = function(verbose)
4446 if not success_req then
4547 vim .api .nvim_err_writeln (
4648 " [rest.nvim] Failed to perform the request.\n Make sure that you have entered the proper URL and the server is running.\n\n Traceback: "
47- .. req_err
49+ .. req_err
4850 )
4951 end
5052end
@@ -65,7 +67,7 @@ rest.last = function()
6567 if not success_req then
6668 vim .api .nvim_err_writeln (
6769 " [rest.nvim] Failed to perform the request.\n Make sure that you have entered the proper URL and the server is running.\n\n Traceback: "
68- .. req_err
70+ .. req_err
6971 )
7072 end
7173end
Original file line number Diff line number Diff line change 167167-- parse_url returns a table with the method of the request and the URL
168168-- @param stmt the request statement, e.g., POST http://localhost:3000/foo
169169local function parse_url (stmt )
170- local parsed = utils .split (stmt , " " )
170+ -- remove HTTP
171+ local parsed = utils .split (stmt , " HTTP/" )
172+ local http_version = nil
173+ if parsed [2 ] ~= nil then
174+ http_version = parsed [2 ]
175+ end
176+ parsed = utils .split (parsed [1 ], " " )
171177 local http_method = parsed [1 ]
172178 table.remove (parsed , 1 )
173179 local target_url = table.concat (parsed , " " )
@@ -176,6 +182,7 @@ local function parse_url(stmt)
176182 method = http_method ,
177183 -- Encode URL
178184 url = utils .encode_url (utils .replace_vars (target_url )),
185+ http_version = http_version
179186 }
180187end
181188
@@ -212,6 +219,7 @@ M.get_current_request = function()
212219 return {
213220 method = parsed_url .method ,
214221 url = parsed_url .url ,
222+ http_version = parsed_url .http_version ,
215223 headers = headers ,
216224 body = body ,
217225 bufnr = bufnr ,
Original file line number Diff line number Diff line change 11###
2- # test with Host
32
43GET /api/users?page=5
54Host: https://reqres.in
65
76###
8- # test with port
7+
8+ GET /api/users?page=5 HTTP/1.1
9+ Host: reqres.in:443
10+
11+ ###
12+
13+ GET /api/users?page=5 HTTP/1.1
14+ Host: reqres.in:80
15+
16+ ###
17+
18+ GET /api/users?page=5 HTTP/1.1
19+ Host: reqres.in
20+
21+ ###
22+
23+ GET /api/users?page=5 HTTP/1.1
24+ Host: https://reqres.in:443
25+
26+ ###
927
1028GET /api/users?page=5
1129Host: https://reqres.in:443
You can’t perform that action at this time.
0 commit comments