Skip to content

Commit 24c31a1

Browse files
dblankentpope
authored andcommitted
Auto-detect https server binding
Resolves: tpope#592
1 parent 12b2f1a commit 24c31a1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

autoload/rails.vim

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,6 @@ function! rails#get_binding_for(pid) abort
19881988
elseif executable('netstat')
19891989
let output = system('netstat -antp')
19901990
let binding = matchstr(output, '\S\+:\d\+\ze\s\+\S\+\s\+LISTEN\s\+'.a:pid.'/')
1991-
return empty(binding) ? '' : 'http://' . s:sub(binding, '^([^[]*:.*):', '[\1]:')
19921991
else
19931992
let binding = ''
19941993
endif
@@ -1997,7 +1996,15 @@ function! rails#get_binding_for(pid) abort
19971996
if empty(binding)
19981997
return ''
19991998
endif
2000-
return 'http://' . binding
1999+
let accepts_ssl = 0
2000+
if s:webcat() =~# '^curl'
2001+
call system('curl --max-time=2 -k --silent --head --fail ' . shellescape('https://'.binding))
2002+
let accepts_ssl = !v:shell_error
2003+
elseif s:webcat() =~# '^wget'
2004+
call system('wget --timeout=2 --no-check-certificate --method=HEAD -q -S ' . shellescape('https://'.binding))
2005+
let accepts_ssl = !v:shell_error
2006+
endif
2007+
return (accepts_ssl ? 'https://' : 'http://') . binding
20012008
endfunction
20022009

20032010
function! s:ServerCommand(kill, bg, arg) abort

0 commit comments

Comments
 (0)