vim http://... support via netrw doesn't inspect Content-Type header

Bug #364548 reported by Dominic Evans
4
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/vim/vim72/autoload/netrw.vim
...
if !exists("g:netrw_http_cmd")
 if executable("elinks")
  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://paste.ubuntu.com/155255/plain/ then I want to do `vim http://paste.ubuntu.com/155255/plain/` and receive that in my buffer for viewing/editing.

$ curl -v http://paste.ubuntu.com/155255/plain/ 2>&1 | grep Content-Type
< 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/dpkg/info/vim.list]
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

Revision history for this message
Dominic Evans (oldmanuk) wrote :

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

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.