[viewvc-dev] ViewVC download link not behaving as expected

Jeremiah Engelman <[email protected]> Fri, 20 Aug 2010 17:09:39 -0700
Newsgroups gmane.comp.version-control.cvs.viewcvs.devel
Message-ID <[email protected]>
I was receiving a lot of grief from co-workers because ViewVC's 
download link did not behave as expected (like the download link in 
cvsweb). Some of their binaries don't have extensions, so it wasn't 
possible to manually handle the mime type.

I tried solving this problem months ago, but made no progress (I don't 
know anything about writing code).

I made a change today that seems to make everything work the way one 
would expect. I changed the default mime type from 'text/plain' to 
'application/octet-stream' in the viewvc.py file at line 2581.

I'm sure this isn't the best way to handle it, but its what I've come up 
with.

Now the download links always ask to download. The 'as text' links still 
load in the browser. Tested with IE8 and FF3.5.

I got to this by looking at a patch written a long time ago to add a 
Content-Disposition header I found near the bottom of the page at:
http://permalink.gmane.org/gmane.comp.version-control.viewvc.user/638

Here is the original code:
   # The revision number acts as a strong validator.
   if not check_freshness(request, None, revision):
     mime_type = request.query_dict.get('content-type') \
                 or calculate_mime_type(request, path, rev) \
                 or 'text/plain'
     server_fp = get_writeready_server_file(request, mime_type)
     copy_stream(fp, server_fp)
   fp.close()

Thanks,
jpe

-- 
Jeremiah Engelman, P.E.
Staff Engineer
ICx Radar Systems (Scottsdale)
1505 N Hayden Rd
Suite 105
Scottsdale, Arizona 85257
(480) 483-1997 #229 phone
(480) 444-6868 cell
(480) 483-2011 fax
www.icxradarsystems.com
www.icxt.com

------------------------------------------------------
http://viewvc.tigris.org/ds/viewMessage.do?dsForumId=4251&dsMessageId=2649368

To unsubscribe from this discussion, e-mail: [[email protected]].
jeremiah_engelman.vcf (text/x-vcard, 199 B)
begin:vcard
fn:Jeremiah Engelman, P.E.
n:Engelman;Jeremiah
email;internet:[email protected]
tel;work:480 483-1997  ext. 229
tel;fax:480 483-2011
tel;cell:480 442-6868
version:2.1
end:vcard