Hi Folks,
Ive not had call to use this before and I want to make sure I understand it before I spend a bunch of time today rewriting something
I need to be able to insert some extra headers into a webFile being sent from a web app. Unfortunately it doesnt appear you can do this with the webFile and webPicture objects as they are currently, correct me if Im wrong about that though! (feature request link here: <https://xojo.com/issue/42941> ) so Im going to work up my own version of the same thing where I can send headers from a handleURL call.
I want to do something similar where the link to the file is valid only while the object is valid in memory. Normally I would create a uniqueID for the object and put that into a global dictionary. The handleURL method would pull that ID out of the path, look up the object and send its data. But this creates another reference to the object in the dictionary and the object will never be removed.
What I think I want to do is create a weakRef object from the class and put that into the dictionary.
That wont count as another reference to the object, so when it goes out of scope in my code the destructor of the class will run normally and I can remove the weakRef from the dictionary in that event. If the weakref returns nil or isnt in the dictionary I can return a not found page.
This way I dont have to add another call to close or something that does that work all through the code that uses these, I can use the destructor to remove the class from the global index.
Do I understand that properly? The weakRef will let me get the object as long as its still referenced somewhere, but doesnt count as a reference itself so the object will go out of scope normally?