|
|
Home » U++ Library support » U++ MT-multithreading and servers » Http file download question
Http file download question [message #36383] |
Wed, 23 May 2012 15:33 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Hello all
I am an absolute dummy in Http.
Based in nice GuiWebDownload demo I wanted to download a file. It works for default address " http://downloads.sourceforge.net/project/upp/upp/4179/upp-x1 1-src-4179.tar.gz" but not the intranet address I am trying. I this case it just returns .html text enclosed below.
Is there perhaps a way to do something else to inform the http server that I want to download that file?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<!-- turing_cluster_prod -->
<html>
<head>
<title>myintranet.com</title>
<meta name="keywords" content="myintranet.com">
<meta name="description" content="myintranet.com">
<meta name="robots" content="INDEX, FOLLOW">
<meta name="revisit-after" content="10">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
cookie_callback = function(val) {
var exdate=new Date();
exdate.setFullYear(exdate.getFullYear() + 1);
document.cookie = "Spusr=" + escape(val) +
"; expires=" + exdate.toUTCString();
document.cookie = "jsc=1";
}
</script> <script src="http://dsparking.com/?epl=K1r1PWFL4whaUopc-k_sfvl965SQUDhFchf_sgtFFDZmEM9xLcww6D2D4Foq9H3fDGpm0AEDjY5GA22FLci0zrMUnBwoBQN6Tt3TMBlFCvuC9zXtFdo4BnVJ0lZSokakthURfpJVnlYDJnsBrmd8X_jATD0AqH6q6ZmoaZqmn6pBGgYa0MQ0MuWpBpUAIGDc778AAOB_AQAAQIBbCgAA-X3rlFlTJllBMTZoWkKdAAAA8A">
</script>
</head>
<frameset rows="100%,*" frameborder="no" border="0" framespacing="0">
<frame src="http://www.myintranet.com?epl=VFsGxNHfvy2uTVDVdXhhUFxPrIIgoXCK5C6-cs2zArDoQJQGnMlOuLYGd9Q_l1m4dj9N7K7fm5b0TV4HE0dOXJ8yKBCyqFhuCJ27BoeKHIQw2lYtFz_PpTWijmozkHpqHtVo4umpGgAAANAocgAgENynvwAAoH8BAABAgNsHAACuJ1ZBWVMmWUExNmhaQnIAAADw" name="myintranet.com">
</frameset>
<noframes>
<body>
<a href="http://www.myintranet.com?epl=VFsGxNHfvy2uTVDVdXhhUFxPrIIgoXCK5C6-cs2zArDoQJQGnMlOuLYGd9Q_l1m4dj9N7K7fm5b0TV4HE0dOXJ8yKBCyqFhuCJ27BoeKHIQw2lYtFz_PpTWijmozkHpqHtVo4umpGgAAANAocgAgENynvwAAoH8BAABAgNsHAACuJ1ZBWVMmWUExNmhaQnIAAADw">
Click here to go to myintranet.com </a>.
</body>
</noframes>
</html>
Best regards
Iñaki
|
|
|
|
Re: Http file download question [message #36390 is a reply to message #36386] |
Wed, 23 May 2012 18:51 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Thank you Mirek
Log is here:
HTTP START
Starting status 2 'Resolving host name', url: myintranet
HTTP Execute: Resolving host name
HTTP StartConnect
HTTP AfterConnect
Starting status 6 'Sending request', url: myintranet
HTTP REQUEST myintranet:0
HTTP request:
GET http://myintranet/data/myfile/myfile.pdf HTTP/1.1
URL: http://myintranet/data/myfile/myfile.pdf
Host: myintranet
Connection: close
Accept: */*
Accept-Encoding: gzip
User-Agent: U++ HTTP request
Proxy-Authorization: Basic MjM4NTM6c29ycHJlc2E=
HTTP Execute: Sending request
Starting status 7 'Receiving header', url: myintranet
HTTP Execute: Receiving header
HTTP Header received:
HTTP/1.1 307 Temporarily Moved for Domain Name Expansion
Mime-Version: 1.0
Date: Wed, 23 May 2012 18:45:30 CEST
Connection: close
Proxy-Connection: close
Location: http://www.myintranet.com/data/myfile/myfile.pdf
Content-Length: 1670
HTTP status code: 307
Starting status 8 'Receiving content', url: myintranet
HTTP Execute: Receiving content
HTTP reading data 1670
HTTP Out 1670
--- HTTP redirect http://www.myintranet.com/data/myfile/myfile.pdf
HTTP START
Starting status 2 'Resolving host name', url: www.myintranet.com
HTTP Execute: Resolving host name
HTTP StartConnect
HTTP AfterConnect
Starting status 6 'Sending request', url: www.myintranet.com
HTTP REQUEST www.myintranet.com:0
HTTP request:
GET http://www.myintranet.com/data/myfile/myfile.pdf HTTP/1.1
URL: http://www.myintranet.com/data/myfile/myfile.pdf
Host: www.myintranet.com
Connection: close
Accept: */*
Accept-Encoding: gzip
User-Agent: U++ HTTP request
Proxy-Authorization: Basic MjM4NTM6c29ycHJlc2E=
HTTP Execute: Sending request
Starting status 7 'Receiving header', url: www.myintranet.com
HTTP Execute: Receiving header
HTTP Header received:
HTTP/1.1 200 OK
Cache-Control: private, no-cache, must-revalidate
Pragma: no-cache
Server: Oversee Turing v1.0.0
Content-Encoding: gzip
Content-Type: text/html
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Keep-Alive: timeout=3, max=91
P3P: policyref="http://www.dsparking.com/w3c/p3p.xml", CP="NOI DSP COR ADMa OUR NOR STA"
Set-Cookie: parkinglot=1; domain=.myintranet.com; path=/; expires=Thu, 24-May-2012 16:45:30 GMT
Content-Length: 947
Date: Wed, 23 May 2012 16:45:30 GMT
Via: 1.1 ironport.myhost.com:8080 (IronPort-WSA/7.1.3-021)
Connection: close
Proxy-Connection: close
HTTP status code: 200
Starting status 8 'Receiving content', url: www.myintranet.com
HTTP Execute: Receiving content
HTTP reading data 947
HTTP Out 1744
Best regards
Iñaki
|
|
|
|
|
Re: Http file download question [message #36513 is a reply to message #36383] |
Mon, 04 June 2012 02:58 |
|
Hi Koldo,
Welcome to web development.
When you reply to server, you have to add in response package header the correct mime type and 'Content-Disposition: attachment;'
for more details you can find on Wikipedia website.
Also very good lessons you can take from Node.JS + Connect and Express.JS packages.
I had a requirement to tell to client that it should be downloaded with a specific file name.
I hope if this a solution what are you looking for!
Update: Would you like to implement this job on client side or on server side?
[Updated on: Mon, 04 June 2012 03:08] Report message to a moderator
|
|
|
|
|
|
Re: Http file download question [message #36524 is a reply to message #36518] |
Mon, 04 June 2012 22:08 |
|
it exact what I expected.
Try this link. it is dirrect link.
Ok.
1. When you open the link a JavaScript event On page load is attached.
2. After the time is elapsed, dynamically is created an hidden control (frame with link... or can be something elese. it less important) and it is fired.
3. It open the link: it open the link: http://downloads.sourceforge.net/project/upp/upp/4179/upp-x1 1-src-4179.tar.gz?r=http%3A%2F%2Fwww.ultimatepp.org%2Fforum% 2Findex.php%3Ft%3Dmsg%26th%3D6738%26start%3D0%26&ts=1338 838532&use_mirror=switch
with header:
Request URL:http://downloads.sourceforge.net/project/upp/upp/4179/upp-x11-src-4179.tar.gz?r=http%3A%2F%2Fwww.ultimatepp.org%2Fforum%2Findex.php%3Ft%3Dmsg%26th%3D6738%26start%3D0%26&ts=1338838532&use_mirror=switch
Request Method:GET
Status Code:302 Found
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,ru;q=0.6,en-GB;q=0.4
Connection:keep-alive
Cookie:__utmx=191645736.00024592574091748957:1:1; __utmxx=191645736.00024592574091748957:1338838533:2592000; __utma=191645736.866235001.1338670652.1338810779.1338838044.5; __utmb=191645736.8.9.1338838539021; __utmc=191645736; __utmz=191645736.1338838044.5.5.utmcsr=ultimatepp.org|utmccn=(referral)|utmcmd=referral|utmcct=/forum/index.php; __utmv=191645736.|5=AB%20Test=4091748957%3A1=1
Host:downloads.sourceforge.net
Referer:http://sourceforge.net/projects/upp/files/upp/4179/upp-x11-src-4179.tar.gz/download?use_mirror=switch
User-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
Query String Parametersview URL encoded
r:http://www.ultimatepp.org/forum/index.php?t=msg&th=6738&start=0&
ts:1338838532
use_mirror:switch
Response Headersview source
Access-Control-Allow-Origin:*
Content-Disposition:attachment; filename="upp-x11-src-4179.tar.gz"
Content-Length:0
Content-type:text/html
Date:Mon, 04 Jun 2012 19:35:39 GMT
Location:http://switch.dl.sourceforge.net/project/upp/upp/4179/upp-x11-src-4179.tar.gz
Server:lighttpd/1.4.26
Set-cookie:sf_mirror_attempt=upp:switch:/upp/upp/4179/upp-x11-src-4179.tar.gz; expires=Mon, 4-Jun-2012 19:37:39 GMT; Path=/
4. browser redirects to the advised link: http://switch.dl.sourceforge.net/project/upp/upp/4179/upp-x1 1-src-4179.tar.gz
with header:
Request URL:http://switch.dl.sourceforge.net/project/upp/upp/4179/upp-x11-src-4179.tar.gz
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,ru;q=0.6,en-GB;q=0.4
Connection:keep-alive
Cookie:__utmx=191645736.00024592574091748957:1:1; __utmxx=191645736.00024592574091748957:1338838533:2592000; __utma=191645736.866235001.1338670652.1338810779.1338838044.5; __utmb=191645736.8.9.1338838539021; __utmc=191645736; __utmz=191645736.1338838044.5.5.utmcsr=ultimatepp.org|utmccn=(referral)|utmcmd=referral|utmcct=/forum/index.php; __utmv=191645736.|5=AB%20Test=4091748957%3A1=1
Host:switch.dl.sourceforge.net
Referer:http://sourceforge.net/projects/upp/files/upp/4179/upp-x11-src-4179.tar.gz/download?use_mirror=switch
User-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
Response Headersview source
Accept-Ranges:bytes
Connection:Keep-Alive
Content-Length:38392395
Content-Type:application/x-gzip
Date:Mon, 04 Jun 2012 19:35:39 GMT
ETag:"1e99f7-249d24b-4b20c1b1bc8c0"
Keep-Alive:timeout=15, max=100
Last-Modified:Sat, 19 Nov 2011 01:09:31 GMT
Server:Apache/2.2.16 (Debian)
be careful to the response
Content-Disposition:attachment; filename="upp-x11-src-4179.tar.gz"
this tag server tells to browser that this should be downloaded.
Hope if helped you.
|
|
|
Re: Http file download question [message #36528 is a reply to message #36524] |
Tue, 05 June 2012 08:21 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
tojocky: With all respect, I believe your response is offtopic for this case.
koldo: In Chrome, enter "www.google.com", then click on white area and chosse "Inspect element" from local menu. Bottom pane should be displayed. Choose "Network", then enter your intranet url, Chrome then will log all http traffic.
[Updated on: Tue, 05 June 2012 08:34] Report message to a moderator
|
|
|
Re: Http file download question [message #36529 is a reply to message #36528] |
Tue, 05 June 2012 09:01 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Hello
I have tried to follow Mirek instructions:
Request URL:http://myintranet/myfile.pdf
Request Method:GET
Status Code:304 Not Modified
Request Header
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:es-ES,es;q=0.8
Authorization:Negotiate TlRMTVNTUAADAAAAGAAYAGoAAAAYABgAggAAAAoACgBIAAAACgAKAFIAAAAOAA4AXAAAAAAAAACaAAAABYKIogUBKAoAAAAPTgBUAEIASQBPADIANAAzADMAMABCAFAAQwA4ADUAMQA5AIMiUdgjK1sgAAAAAAAAAAAAAAAAAAAAACl6K/jgsz1Xxi4Wp7mGrOE5hKlEekRitg==
Cache-Control:max-age=0
Connection:keep-alive
Cookie:UserType=P; idioma=es%2DES; ASPSESSIONIDQABDBSDD=DCILLDNCIFEHFLHEEILJJEAD
Host:myintranet
If-Modified-Since:Thu, 10 Nov 2011 14:49:40 GMT
If-None-Match:"3a5dcbf9b79fcc1:0"
Range:bytes=0-1048575
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
Response Headers
Accept-Ranges:bytes
Date:Tue, 05 Jun 2012 06:50:15 GMT
ETag:"3a5dcbf9b79fcc1:0"
Last-Modified:Thu, 10 Nov 2011 14:49:40 GMT
MS-Author-Via:MS-FP/4.0
MicrosoftOfficeWebServer:5.0_Pub
Server:Microsoft-IIS/7.0
X-Powered-By:ASP.NET
In addition I have found that when entering the address directly in the browser I get the file downloaded if I use Internet Explorer and Chrome. However if I use Firefox I get the same html page I get when using the U++ program.
Best regards
Iñaki
|
|
|
Re: Http file download question [message #36536 is a reply to message #36529] |
Tue, 05 June 2012 23:02 |
|
Mirek: Thank you. maybe I'm wrong.
Koldo: if I understood you correctly, you want to download a file from a server. You want to make the sever to communicate with browser for downloading a file. If yes, then I think you should put in response header package tags (you missed):
1. Content-Type: more detaild is described here
2. Content-Disposition:attachment; filename="<wanted file name for save>"
3. Content-Length: <your file length>
Let me know if I'm wrong.
Sorry for confuse you if I was.
|
|
|
|
|
|
|
|
Re: Http file download question [message #36695 is a reply to message #36694] |
Tue, 26 June 2012 13:03 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Hello Mirek
Yes of course . If I do not put any password it does not download anything.
With the password it downloads the html page in the first post.
It is funny that I get the same html page using Firefox but I get the file using Chrome or Explorer.
Best regards
Iñaki
[Updated on: Tue, 26 June 2012 13:03] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 15:43:19 CEST 2024
Total time taken to generate the page: 0.02511 seconds
|
|
|