Skip to content
Snippets Groups Projects
Commit acfb9fa4 authored by Thomas Arendsen Hein's avatar Thomas Arendsen Hein
Browse files

hgweb: Pass only filename instead of full path when downloading raw files.

Before this patch "filename=foo/bar" was sent and e.g. Firefox offered to save
the file as "foo-bar" instead of just "bar".
parent be91a77b
No related branches found
No related tags found
No related merge requests found
......@@ -85,8 +85,8 @@
if type is not None:
headers.append(('Content-Type', type))
if filename:
headers.append(('Content-Disposition', 'inline; filename=%s' %
filename))
headers.append(('Content-Disposition',
'inline; filename=%s' % filename.split('/')[-1]))
if length:
headers.append(('Content-Length', str(length)))
self.header(headers)
......
......@@ -2,9 +2,10 @@
hg init test
cd test
cat >sometext.txt <<ENDSOME
mkdir sub
cat >sub/sometext.txt <<ENDSOME
This is just some random text
that will go inside the file and take a few lines.
It is very boring to read, but computers don't
care about things like that.
ENDSOME
......@@ -6,9 +7,9 @@
This is just some random text
that will go inside the file and take a few lines.
It is very boring to read, but computers don't
care about things like that.
ENDSOME
hg add sometext.txt
hg add sub/sometext.txt
hg commit -d "1 0" -m "Just some text"
hg serve -p $HGPORT -A access.log -E error.log -d --pid-file=hg.pid
cat hg.pid >> $DAEMON_PIDS
......@@ -12,7 +13,7 @@
hg commit -d "1 0" -m "Just some text"
hg serve -p $HGPORT -A access.log -E error.log -d --pid-file=hg.pid
cat hg.pid >> $DAEMON_PIDS
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/?f=f165dc289438;file=sometext.txt;style=raw' content-type content-length content-disposition) >getoutput.txt &
("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/?f=37afcac6d393;file=sub/sometext.txt;style=raw' content-type content-length content-disposition) >getoutput.txt &
sleep 5
kill `cat hg.pid`
......
......@@ -7,4 +7,4 @@
that will go inside the file and take a few lines.
It is very boring to read, but computers don't
care about things like that.
host - - [date] "GET /?f=f165dc289438;file=sometext.txt;style=raw HTTP/1.1" 200 -
host - - [date] "GET /?f=37afcac6d393;file=sub/sometext.txt;style=raw HTTP/1.1" 200 -
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment