vim http://... support via netrw doesn't inspect Content-Type header
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
vim (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: vim
Running `vim http://...` with a .vimrc to enable netrw works very differently depending on whether or not you have elinks or links installed. As you can see from the netrw code below, as soon as you have either of the text browsers installed, netrw will invoke them to do a dump of html --> txt and put that into your vim buffer. However, this takes no account of the Content-Type header of the remote server so is less than ideal.
$ cat .vimrc
set nocp " 'compatible' is not set
filetype plugin on " plugins are enabled
$ cat /usr/share/
...
if !exists(
if executable(
let g:netrw_http_cmd = "elinks"
let g:netrw_http_xcmd= "-dump >"
elseif executable("links")
let g:netrw_http_cmd = "links"
let g:netrw_http_xcmd= "-dump >"
elseif executable("curl")
let g:netrw_http_cmd = "curl -o"
elseif executable("wget")
let g:netrw_http_cmd = "wget -q -O"
elseif executable("fetch")
let g:netrw_http_cmd = "fetch -o"
else
let g:netrw_http_cmd = ""
endif
endif
...
Ideally, if I know a remote plain/text file is available at URL http://
$ curl -v http://
< Content-Type: text/plain
However, if the remote Content-Type is text/html then I may want elinks -dump to proceed as normal.
ProblemType: Bug
Architecture: i386
Dependencies:
DistroRelease: Ubuntu 9.04
Package: vim None [modified: /var/lib/
ProcEnviron:
SHELL=/bin/bash
PATH=(custom, user)
LANG=en_GB.UTF-8
SourcePackage: vim
Uname: Linux 2.6.28-11-generic i686
UnreportableReason: This is not a genuine Ubuntu package
In addition the curl command should really be:
elseif executable("curl")
let g:netrw_http_cmd = "curl -Ls -o"
to use quiet output that follows redirections (like the wget one), otherwise a redirect results in an empty vim buffer