Open pinggit opened 6 years ago
I saw a closed old issue: Auto Formatting Response Doesn't Work #47
I tried '-i' knob but it does not work...
I'm trying to test this plugin and see how it can be integrated into my work flow. it seems very interesting one. reading through README to test now...
Try :help vrc_auto_format_response_patterns
You can check out vrc_auto_format_response_patterns
option in the help file. It has a good explanation on formatting response. In short, if Content-Type
header is not present, VRC can't do anything; however, if you already know the content type, you can always set it to the option vrc_response_default_content_type
as
let g:vrc_response_default_content_type = 'application/json'
When you try the -i
option, how does the output look like?
this is my testfile.rest
http://localhost:8095
-i
-u admin:abc
#GET /virtual-network/5e5f3cf7-b1aa-4b91-976e-23350916ccf7
GET /access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45
http://localhost:8095
-Ss
-u admin:abc
GET /virtual-network/5e5f3cf7-b1aa-4b91-976e-23350916ccf7
I hit enter when cursor is in first block, and got this:
"__REST_response__" [New File]
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
Press ENTER or type command to continue
I hit enter, and in output buffer I got this:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/1.1 200 OK
Content-Length: 4526
Etag: "2018-06-01T13:21:45.811389"
Content-Type: application/json
Date: Wed, 06 Jun 2018 04:19:52 GMT
after removing -i I got the output content in the buffer. but all in one superlong one line... it looks -i does not work for me.
Probably the server returns something unexpected. Will have to debug your request. Please follow these steps.
:let g:vrc_show_command = 1
:let g:vrc_debug = 1
:mes
. This should show some output, please paste it here as well.You can remove any sensitive info from your console output and command.
with the 2 vim vars set, I got the same error, ignored them, then these from output buffer:
* Rebuilt URL to: admin:abc/
* Hostname was NOT found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Could not resolve host: admin
* Closing connection 0
curl: (6) Could not resolve host: admin
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 8095 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8095 (#1)
* Server auth using Basic with user 'admin'
> GET /access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45 HTTP/1.1
> Authorization: Basic YWRtaW46SnVuaXBlcg==
> User-Agent: curl/7.35.0
> Host: localhost:8095
> Accept: */*
> Content-Type: application/json
>
< HTTP/1.1 200 OK
< Content-Length: 4526
< Etag: "2018-06-01T13:21:45.811389"
< Content-Type: application/json
< Date: Wed, 06 Jun 2018 04:46:51 GMT
<
{ [data not shown]
HTTP/1.1 200 OK
Content-Length: 4526
Etag: "2018-06-01T13:21:45.811389"
Content-Type: application/json
Date: Wed, 06 Jun 2018 04:46:51 GMT
curl commands being executed:
|| curl -u 'admin:abc' -v 'admin:abc' -H 'Content-Type: application/json' -i --get 'http://localhost:
8095/access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45'
:mes gives:
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:32)
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
"vim-rest-console.txt" [readonly] 664L, 23117C
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
E121: Undefined variable: s:vrc_auto_format_response_patterns
1 more line; before #10 21:31:18
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_GetCurlCommand..vrc#opt#DictToCurlArgs:
line 2:
E706: Variable type mismatch for: optVal
[Debug] Command: curl -u 'admin:abc' -v 'admin:abc' -H 'Content-Type: application/json' -i --get 'http://localhost:8095/access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45'
[Debug] cUrl options: {'-u': ['admin:abc'], '-v': '', '-H': ['Content-Type: application/json'], '-i': []}
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_GetCurlCommand..vrc#opt#DictToCurlArgs:
line 2:
E706: Variable type mismatch for: optVal
[Debug] Command: curl -u 'admin:abc' -v 'admin:abc' -H 'Content-Type: application/json' -i --get 'http://localhost:8095/access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45'
[Debug] cUrl options: {'-u': ['admin:abc'], '-v': '', '-H': ['Content-Type: application/json'], '-i': []}
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_GetCurlCommand..vrc#opt#DictToCurlArgs:
line 2:
E706: Variable type mismatch for: optVal
[Debug] Command: curl -u 'admin:abc' -v 'admin:abc' -H 'Content-Type: application/json' -i --get 'http://localhost:8095/access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45'
[Debug] cUrl options: {'-u': ['admin:abc'], '-v': '', '-H': ['Content-Type: application/json'], '-i': []}
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
Press ENTER or type command to continue
looks like the -v xxx caused the problem?
Hmm it's weird. Did you add -v
somewhere?
Ah nvm, it's the result of debug. One thing I notice is that the data part ({ [data not shown]
) comes before the header part. And it's also weird that the credentials follow -v
in the command. Normally, -v
should be on its own.
as long as I remove the '-i' line, it will works, but not formatted...and that is my original question...
When I don't set anything for VRC in .vimrc
, executing this request
http://localhost:9200
-i
-u hello:world
GET /testindex/_search
gives me this info output
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 1209 100 1209 0 0 121k 0 --:--:-- --:--:-- --:--:-- 131k
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 1209
{ [data not shown] }
and this debug info
[Debug] Command: curl -u 'hello:world' -v -H 'Content-Type: application/json' -i --get 'http://localhost:9200/testindex/_search'
[Debug] cUrl options: {'-u': ['hello:world'], '-v': '', '-H': ['Content-Type: application/json'], '-i': []}
The -v
option is on its own.
I can manually use this below to format manually in the output buffer :'<,'>!python -mjson.tool but everytime I trigger new execution, it set "nomodifiable", even after I manually set modifiable. is this set for a reason? can this setting be removed?
Error detected while processing function VrcQuery..<SNR>55_RunQuery..<SNR>55_DisplayOutput:
line 63:
E730: using List as a String
what does that E730 indicate?
Currently there is no way to turn off nomodifiable
. This can be set by introducing a new option.
I think the main issue is that the response header comes after the data part. Can you verify this by running this command in a shell.
curl -u 'admin:abc' -H 'Content-Type: application/json' -i --get 'http://localhost:8095/access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45'
E730
is Vim internal error indicating that message. For that error, usually it's due to an unexpected output.
I found another interesting test result... if I add this in .vimrc only, with same rest file it works:
let g:vrc_show_command = 1
I remove it from .vimrc and re-test, again there is same issue...
and yes, what you gave work in the shell.
$ curl -u 'admin:abc' -H 'Content-Type: application/json' -i --get 'http://localhost:8095/access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45'
HTTP/1.1 200 OK
Content-Length: 4526
Etag: "2018-06-01T13:21:45.811389"
Content-Type: application/json
Date: Wed, 06 Jun 2018 05:21:10 GMT
{"access-control-list": {"display_name": "MNS-25180-P-BOT1A_dmz_protected_net_1", "uuid": "427bd58a-de4a-4599-9bd1-12200a5fad45", "parent_uuid": "5e5f3cf7-b1aa-4b91-976
k/5e5f3cf7-b1aa-4b91-976e-23350916ccf7", "parent_type": "virtual-network", "perms2": {"owner": "5d70101e0c5f44c690a89690e93da690", "owner_access": 7, "global_access": 0
f": "http://localhost:8095/access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45", "id_perms": {"enable": true, "description": null, "created": "2018-04-02T18:33:30.
Hmm it's really weird. The command output looks normal. Maybe you can try reinstalling VRC.
rest
file so that you don't have to retype later then quit vim.rest
file and try the first block.I tried exactly the above suggested, still same exact issue. with this in .vimrc It works fine:
let g:vrc_show_command = 1
now question is, why does the auto format never worked?
this is probably vim 7.4 issue.
so I changed another machine with same exact ubuntu/vim release, got same result.
:version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:32)
Included patches: 1-52
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by buildd@
Huge version without GUI. Features included (+) or not (-):
+acl +cmdline_info +emacs_tags -hangul_input +menu +mouse_xterm -python3 +syntax +virtualedit -xsmp
+arabic +comments +eval +iconv +mksession +multi_byte +quickfix +tag_binary +visual -xterm_clipboard
+autocmd +conceal +ex_extra +insert_expand +modify_fname +multi_lang +reltime +tag_old_static +visualextra -xterm_save
-balloon_eval +cryptv +extra_search +jumplist +mouse -mzscheme +rightleft -tag_any_white +viminfo -xpm
-browse +cscope +farsi +keymap -mouseshape +netbeans_intg -ruby -tcl +vreplace
++builtin_terms +cursorbind +file_in_path +langmap +mouse_dec +path_extra +scrollbind +terminfo +wildignore
+byte_offset +cursorshape +find_in_path +libcall +mouse_gpm -perl +signs +termresponse +wildmenu
+cindent +dialog_con +float +linebreak -mouse_jsbterm +persistent_undo +smartindent +textobjects +windows
-clientserver +diff +folding +lispindent +mouse_netterm +postscript -sniff +title +writebackup
-clipboard +digraphs -footer +listcmds +mouse_sgr +printer +startuptime -toolbar -X11
+cmdline_compl -dnd +fork() +localmap -mouse_sysmouse +profile +statusline +user_commands -xfontset
+cmdline_hist -ebcdic +gettext -lua +mouse_urxvt +python -sun_workshop +vertsplit -xim
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation:
gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib/python2.7/config-x86_
64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
my minimum rest file to reproduce this:
http://localhost:9100
-i
-u admin:abc
#GET /virtual-network/5e5f3cf7-b1aa-4b91-976e-23350916ccf7
GET /
my minimum vimrc files to reproduce:
set nocp
if empty(glob('~/.vim/autoload/pathogen.vim'))
silent !curl -fLo ~/.vim/autoload/pathogen.vim --create-dirs
\ https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
endif
execute pathogen#infect()
with vim8.0 and same files I don't see the problem...
Shoot, it might be backward compatibility issue since I've updated to Vim 8 for a while, I forget about Vim 7.4. I will need this version to reproduce the issue. Are you fine with using Vim 8 or must it be 7.4?
What puzzles me is let g:vrc_show_command = 1
makes it work. Really strange. Let me look at that part more carefully.
With your fresh install of VRC on Vim 7.4 and vrc_show_command = 1
, is the executed command shown like this one (no -v
)?
curl -u 'admin:abc' -H 'Content-Type: application/json' -i --get 'http://localhost:
8095/access-control-list/427bd58a-de4a-4599-9bd1-12200a5fad45'
I've done some test with Vim 7.4 (on mac) here, https://github.com/diepm/vim-rest-console/issues/63#issuecomment-395308561, but can't reproduce your issue.
after I set this in the .vimrc
let g:vrc_curl_opts = {
\ '-sS': '',
\ '--connect-timeout': 10,
\ '-i': '',
\ '--max-time': 60,
\ '-k': '',
\}
it works, I'm using vim 8.1
For me it didn't work, until I figured out that I didn't have python installed.
after I set this in the
.vimrc
let g:vrc_curl_opts = { \ '-sS': '', \ '--connect-timeout': 10, \ '-i': '', \ '--max-time': 60, \ '-k': '', \}
it works, I'm using vim 8.1
Thanks, it works
the output is only 1 line always. is there a way to automatically display the formatted output , e.g. using python -mjson.tool ?