Need help with http download
I have a json file I need to download to my server or read and put it into a string from a remote website every 15 secs.
I'd probably use the Jamison Extension to read the json file/string once I have it. My original plan was to use cURL to download the file but my GSP wont update VC++ so that it runs correctly. My thought now is to use Steamtools rather than Socket. I think I have an idea of what the code I want is to look like but I need to know where SteamTools downloads the file in the file system. Or if anyone else has any better ways of doing this, I'm all ears. |
Re: Need help with http download
Look at the example here.
Steam_WriteHTTPResponseBody is based in the server's current directory, use SM's BuildPath native to create a path to the SM data folder if you need a sane temporary location - if whatever you're parsing it with can just take a string of data, don't write it out at all and use Steam_GetHTTPResponseBodyData instead. |
Re: Need help with http download
Thanks asherkin. I found a store plugin that used Steam_GetHTTPResponseBodyData So i tried that out. It downloaded the json file into a string and then (because I'm lazy this afternoon) outputted the result to the ErrorLog. I only got the first 1024 chars outputted though. Is that a limitation with SteamTools or the Error handling with the log? The length of the json string is around 8000 chars.
|
Re: Need help with http download
|
Re: Need help with http download
So I am calling this function every 15 secs because that how often the file im grabbing gets updated. I can pull it up and refresh it in a browser and watch the changes.
It is indeed outputting info to the Error Log every 15 secs. On rare occasion it errors. The problem is that it is not downloading the updated file. Its like it downloading the cache of the file or something. Only about 3 times during a 30 min period did it download the current file. Any ideas? Code:
public UpdateData() |
Re: Need help with http download
Make sure the server is sending proper headers to block caching, it's very aggressive about following the spec.
|
Re: Need help with http download
yay another fun conversation with my GSP. I can't win.
Yeah for about 7-15 minutes it downloads the right info then for another 7-15 mins it downloads a cached version, rinse, repeat. If they refuse to help me I may just have 10 of the same file generated and numbered then download them in sequence. That's so ghetto. |
Re: Need help with http download
Quote:
Code:
Steam_SetHTTPRequestHeaderValue(hRequest, "Pragma", "no-cache"); |
Re: Need help with http download
|
All times are GMT -4. The time now is 03:56. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.