Page 1 of 1
headers respond
Posted: Tue Nov 05, 2013 10:27 am
by boysky76
I have to download a file from a link in this link if called httpheaders the link redirects to the server, and then starts the download, if I insert "LibUrlFollowRedirects false" then the response headers I see the link of the server, but if I leave "LibUrlFollowRedirects true "in the header can not see the file name, that I need to insert it later in the" LibUrlDownloadToFile "as the name of the file to salvare.Il first link I can not use it because it serves only as a redirect, the second link works with" LibUrlDownloadToFile "but i have not the name that appears to be in the header, if I use" get url (linkname2) "to have httpheders with the name LiveCode remains very slow because you download the entire file into memory before to give me back the headers.
How do I get the headers without downloading the file first?
I hope I have explained my problem well
Re: headers respond
Posted: Wed Nov 06, 2013 12:08 am
by boysky76
I found this solution, however, are not happy with this, then I download the file with (liburldownloadtofile turl,tname, "downloadDone") after I extract the name from the header Respond, and rename the file.
But I wish I could first see the name of the file and then download.
Someone suggests to me other ideas.
;)
Re: headers respond
Posted: Wed Nov 06, 2013 12:10 am
by Simon
Hi boysky76,
How is the redirect being done? In meta tags, javascript etc.
What is the URL of the first link?
Simon
Re: headers respond
Posted: Wed Nov 06, 2013 12:45 am
by boysky76
hi,
the first link is : http://w w w.sitename.com/ddl2/aHR0cDovL3d3dy5ub3d2aWRlby5jaC92aWRlby9kMWQzN2U3NTg0Nzg5fDcyNzg4fDFxd2VydHl8
Get Url (link1)
this is the http respond headers and contains the redirect url
--HTTP/1.1 302 Found
Date: Tue, 05 Nov 2013 12:21:48 GMT
Server: Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.3.17
X-Powered-By: PHP/5.3.17
Location:
http://nl1a.sitename.com/name.php?type= ... I3MzQ2NDM=
Content-Length: 0
Connection: close
Content-Type: text/html--
if i set libURLFollowHttpRedirects false I can extract the location and put thsi in "tlocation" and use liburldownloadtofile (tlocation,tfilename) for download the file.
If I set libURLFollowHttpRedirects true livecode freezes or slows down because it is a large file and need "liburldownloadtofile" for download
but before to download i need extract the "Content-Disposition: " present in the http headers But I can see that only after I run the command "get" or "liburldownloadtofile" with the tlocation
HTTP/1.1 200 OK
Date: Tue, 05 Nov 2013 12:21:46 GMT
Server: Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.3.21
X-Powered-By: PHP/5.3.21
Content-Disposition: attachment; filename="ff4e219a21ed3e22cf68dba97753b9cb0c.flv"
Etag: "3524601224"
Accept-Ranges: bytes
Last-Modified: Mon, 05 Aug 2013 14:26:34 GMT
Expires: Wed, 06 Nov 2013 04:21:10 GMT
Cache-Control: max-age=28800
Content-Length: 115991455
Connection: close
Content-Type: application/octet-stream
----------------
Re: headers respond
Posted: Wed Nov 06, 2013 1:26 am
by Simon
Actually I was hoping you would post the actual URL you are using. Can't try to help without knowing what is going on.
Simon
Re: headers respond
Posted: Wed Nov 06, 2013 8:44 am
by boysky76
Re: headers respond
Posted: Wed Nov 06, 2013 11:57 pm
by Simon
Hi boysky76,
I've got an answer for you ... might not be a good answer.
Here are the commands I used, see if you can put it together in your stack.
libURLSetLogField --Specifies a field for logging information about uploads and downloads. like the headers
resetAll --Closes all open sockets and halts all pending Internet operations. Lets you stop a download
Now with just those two can you figure out a way to make them work to grab the .flv name?
Simon
Re: headers respond
Posted: Thu Nov 07, 2013 2:37 am
by boysky76
Hi simon
thanks for the answers, but even if I use "resetall" LiveCode appears to hang or rellentare very much as if the memory was not freed and called Get the url (link) to continue to load the data into memory, slowing everything
Re: headers respond
Posted: Thu Nov 07, 2013 3:05 am
by Simon
I used put url "http://your_link" into temp
then resetAll
That was working here.
Simon
Re: headers respond
Posted: Fri Nov 08, 2013 12:47 am
by boysky76
To me it keeps crashing the stack, as if the "resetall" fails to close all sockets.
the browser can read this header and take the name, I should simulate this. Basically something like this:
Liburldownloadtofile Link, tname (headers to extract libUrlLastRHHeaders), "DownloadDone"
Re: headers respond
Posted: Fri Nov 08, 2013 2:12 am
by Simon
Try the attached stack and tell me what happens.
In the button script there is a time delay which you may have to adjust.
Simon
Re: headers respond
Posted: Fri Nov 08, 2013 8:09 am
by Tribblehunter
Watching with interest as I am doing something similar.
Re: headers respond
Posted: Sat Nov 09, 2013 1:00 am
by boysky76
the script you sent me works, I thank you, the problem is that I now have, is that my application should extract different url one after the other and when you run the first time the command "resetall" I closed everything and I should start the script again, but by doing restart takes up the first url and not the second. (it is a bit 'complicated)
Re: headers respond
Posted: Sat Nov 09, 2013 1:27 am
by Simon
Hello boysky76,
I'm not clear on the problem you are having. Is it just a repeat loop you are asking about?
If so just stick your url's into a variable and loop through the code.
Simon