diepm / vim-rest-console

A REST console for Vim.
658 stars 54 forks source link

Curl Progress Meter is Disruptive #71

Open dvisztempacct opened 5 years ago

dvisztempacct commented 5 years ago

I've been running curl from the vim command line for a while now and have not been able to figure out how to get curl to two important things at the same time:

1) Silence the progress meter 2) Display server responses on failure response status

It looks like this plugin suffers the same humiliation:

screenshot from 2019-01-29 12-38-57

IMO the progress meter is annoying and irrelevant 99.9% of the time.

Maybe a different http client would work better?

dvisztempacct commented 5 years ago

Actually, the progress meter goes is written to stderr, so for my use cases, curl could still work, as long as stderr is redirected somewhere (/dev/null)

dvisztempacct commented 5 years ago

This works for me:

diff --git a/ftplugin/rest.vim b/ftplugin/rest.vim
index 2dea5c6..c0857a4 100644
--- a/ftplugin/rest.vim
+++ b/ftplugin/rest.vim
@@ -738,7 +738,7 @@ function! s:RunQuery(start, end)
     silent !clear
     redraw!

-    call add(outputInfo['outputChunks'], system(curlCmd))
+    call add(outputInfo['outputChunks'], system(curlCmd . ' 2> /dev/null'))
     if shouldShowCommand
       call add(outputInfo['commands'], curlCmd)
     endif

Maybe this could become a configurable behavior :)

diepm commented 5 years ago

Have you tried with -s and -S option? /dev/null won't work for Windows users though.

dvisztempacct commented 5 years ago

@diepm no combination of arguments I could find actually produced the result I wanted, which was to always see the response body even if the HTTP status indicates an error, and no progress output.

I'm not sure what Windows users can do, but maybe this can be put in a check for paltform, or for if the file exists.

taybart commented 5 years ago

@dvisztempacct try this

" vim-rest-console
let g:vrc_curl_opts = {
  \ '--connect-timeout' : 10,
  \ '-b': '/path/to/cookie',
  \ '-c': '/path/to/cookie',
  \ '-L': '',
  \ '-i': '',
  \ '-s': '',
  \ '--max-time': 60,
  \ '--ipv4': '',
  \ '-k': '',
\}