How to clear the socket cache.
Moderator: Klaus
How to clear the socket cache.
I would like to do this with LiveCode because of the multi-platform capability.
Part of this is the requirement to login to the site and navigate to the posts part of the dashboard.
To stay logged in to Wordpress it is essential to manage the cookies and follow redirects.
I have done this using Python, Phantomjs, Pure Basic and simpletest (a PHP unit testing framework).
I couldn't get it to work with TCL/TK or Freepascal so I do understand the process and that it is a non-trivial process.
I wrote my first serious program with Hypercard in the late 80's, a cash register program for a service station, and am delighted to be reacquainted with it through LiveCode.
Having established some slight credentials let's get to the problem.
I am getting intermittent and unreliable logging. I have crawled the forums for post type comments but nothing seems to cover the issue I am having.
It seems to me that LC caches the http headers and returns them regardless of the URL I call.
Sometimes it even seems to cache the headers I send and resend them instead of the proper ones.
I have attached a sample stack which demonstrated the problem.
Changing the URL in the URL field works for the first few times but then it starts to get hung up and returns the same recieved headers almost regardless of the requested site.
I test with google, amazon, ebay, adobe, apple, microsoft, gmail etc. but you can also test with pretty much any site you like, the behaviour remains unreliable.
What have I missed? Is this really buggy behaviour ir is it me?
Re: How to clear the socket cache.
Hi ya,
If you are using the "load" command, there is a counterpart called "unload" that should clear the cache. Additionally, you can see what URLs have been cached by using "the cachedURLs" to verify.
Hope that helps.
- Mark
If you are using the "load" command, there is a counterpart called "unload" that should clear the cache. Additionally, you can see what URLs have been cached by using "the cachedURLs" to verify.
Hope that helps.
- Mark
Re: How to clear the socket cache.
Thanks for the quick response.
I thought I had attached the stack but 'twasnt so.
It is now.
You will see in that that I am using load and unload but the behaviour remains buggy.
I will test the cachedUrls call though.
I thought I had attached the stack but 'twasnt so.
It is now.
You will see in that that I am using load and unload but the behaviour remains buggy.
I will test the cachedUrls call though.
Re: How to clear the socket cache.
Hi Ralph,lilRalph wrote:Thanks for the quick response.
I thought I had attached the stack but 'twasnt so.
It is now.
You can't attached a file right now; I think you need few more posts
to be able to do that...
Put ti in your dropbox or anywhere and provide a link to it.
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: How to clear the socket cache.
G'Day Thierry, my first post appears to me to have a downloadable link to the file at the top of the post.
If that isn't the same for you then I'll make alternative arrangements.
I just tried the cachedUrls function and it shows empty while I am requesting amazon and getting ebay headers.
If that isn't the same for you then I'll make alternative arrangements.
I just tried the cachedUrls function and it shows empty while I am requesting amazon and getting ebay headers.
Re: How to clear the socket cache.
Oops, sorry for the noise. There it islilRalph wrote:G'Day Thierry, my first post appears to me to have a downloadable link to the file at the top of the post.

Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: How to clear the socket cache.
Hi,
Managed to make it works with few changes..
BTW, I'm working on a current project which just does what you want,
and I'm quite happy so far with all the tests...
HTH,
Thierry
Managed to make it works with few changes..
Code: Select all
function fnGetStaticHeaders pHost, pCookies,pReferer
put empty into tHeaders
-- if pHost is not empty then put "Host:" && pHost & cr into tHeaders
put cr & "User-Agent: " "e&"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0""e after tHeaders
put cr & "Accept: " "e&"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""e after tHeaders
put cr & "Accept-Language: " "e&"en-gb,en;q=0.5""e after tHeaders
put cr & "Accept-Encoding: " "e&"gzip,deflate""e after tHeaders
put cr & "Connection: " "e&"keep-alive""e after tHeaders
-- if pReferer is not empty then
-- put cr & "Referer:" && pReferer after tHeaders
-- end if
-- if pCookies is not empty then
-- put cr & "Cookie: lang=english;" & pCookies after tHeaders
-- end if
return tHeaders
end fnGetStaticHeaders
and I'm quite happy so far with all the tests...
HTH,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: How to clear the socket cache.
and I changed this settings to have some feedback:
Thierry
Code: Select all
libURLFollowHttpRedirects false -- true
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: How to clear the socket cache.
Thierry that does work and it seems to be reliable. Excellent work.
It is very interesting that putting the quotes around the text makes a difference, I am supposing that LC treats it as a string then as opposed to objects (?).
However, I will need to have the cookies at the very least because, as you would know, Wordpress relies on the cookies for access.
I am happy to not have to use socket manipulation directly.
OK, not a bug.
Thanks.
It is very interesting that putting the quotes around the text makes a difference, I am supposing that LC treats it as a string then as opposed to objects (?).
However, I will need to have the cookies at the very least because, as you would know, Wordpress relies on the cookies for access.
I am happy to not have to use socket manipulation directly.
OK, not a bug.
Thanks.
Re: How to clear the socket cache.
Glad that you're happy with itlilRalph wrote:Thierry that does work and it seems to be reliable. Excellent work.

Well, reading closely at headers, those quotes are mandatories.It is very interesting that putting the quotes around the text makes a difference, I am supposing that LC treats it as a string then as opposed to objects (?).
And yes, it's just plain text.
Check in these forums for an excellent post from sparkout, who explains very nicely andHowever, I will need to have the cookies at the very least because, as you would know, Wordpress relies on the cookies for access.
precisely how to deal with cookies.
Regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: How to clear the socket cache.
Thanks again Thierry, I removed this bit
Removing that part enables the cookies to operate.
I will check out sparkout's cookie handling.
For those who read this later, the link to sparkout's cookie handling is here http://forums.livecode.com/viewtopic.ph ... ers#p86063 .
as I found that LC puts in the Host: part correctly.-- if pHost is not empty then put "Host:" && pHost & cr into tHeaders
Removing that part enables the cookies to operate.
I will check out sparkout's cookie handling.
For those who read this later, the link to sparkout's cookie handling is here http://forums.livecode.com/viewtopic.ph ... ers#p86063 .
Re: How to clear the socket cache.
As I did the first corrections quite fast, it seeems we do *not* need ot add these extra quotes!lilRalph wrote:Thanks again Thierry, I removed this bit
as I found that LC puts in the Host: part correctly.-- if pHost is not empty then put "Host:" && pHost & cr into tHeaders
Removing that part enables the cookies to operate.
So the problem was certainly the double Host definition...
Yep, that's the oneI will check out sparkout's cookie handling.
For those who read this later, the link to sparkout's cookie handling is here http://forums.livecode.com/viewtopic.ph ... ers#p86063 .

So you're in good hands with sparkout expertise

Good lck,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
Re: How to clear the socket cache.
Just for info, the pHost argument there was optional, I included it in the function because it was necessary for the specific site in question on that thread. It would have been better if I had mentioned it, and perhaps more succinctly, would have been better to have made the pHost argument the last one passed to the function, in which case it would be more elegant to leave it out optionally. (On the other hand, all the arguments are optional).
Re: How to clear the socket cache.
Great forum response here. Fast, accurate and not agressive or belittling like some forums.
Keep up the great customer service here and LiveCode is destined for greatness.
Thanks Thierry for your help and feedback. I have also tested the quotes and decided to leave them in even though they seem to be essential.
Thanks also to sparkout for your input. I had read that the headers are replaced rather than required but updating the host shouldn't upset the routine.
I have plans for this programming tool, I hope I'm up to it.
Keep up the great customer service here and LiveCode is destined for greatness.
Thanks Thierry for your help and feedback. I have also tested the quotes and decided to leave them in even though they seem to be essential.
Thanks also to sparkout for your input. I had read that the headers are replaced rather than required but updating the host shouldn't upset the routine.
I have plans for this programming tool, I hope I'm up to it.