Libraries: HTTP requests for new MQL4 (tested in build 600)

 

HTTP requests for new MQL4 (tested in build 600):

Simple library that allows sending requests via HTTP protocol from new MQL4

Author: Sergey

 

I'm finding that this is cacheing some http_get requests so that the the GET request is not even sent and old data is returned. For example if I did:

 

http_result = httpGET("url.php");

 

Where url.php consisted of <?php echo 'hello'; ?>

 

then http_result would output 'hello' as you would expect. But then if I edit url.php to <?php echo 'goodbye'; ?> and save the changes then call

 

http_result = httpGET("url.php");

 

Then http_result still outputs 'hello' instead of 'goodbye'. I'm attempting to avoid this by adding "url.php?t=",TimeSeconds(TimeCurrent()) to the end of the url but this might be a memory leak if the code is cacheing return results.

Thoughts? 

 

Adding to my comment above, I found the following flags in wininet.dll that appear relevant but do not know how to implement them in your code:

INTERNET_FLAG_NO_CACHE_WRITE - does not cache the returned result

INTERNET_FLAG_RELOAD  -forces a download of the file, even if it is already in cache 

 

Any help would be appreciated. 

 

 

Ok, the following changes worked for me:

 In the #import part:

 

#import "wininet.dll"

#define INTERNET_FLAG_PRAGMA_NOCACHE    0x00000100 // Forces the request to be resolved by the origin server, even if a cached copy exists on the proxy.

#define INTERNET_FLAG_NO_CACHE_WRITE    0x04000000 // Does not add the returned entity to the cache. 

#define INTERNET_FLAG_RELOAD            0x80000000 // Forces a download of the requested file, object, or directory listing from the origin server, not from the cache. 

 ....

#import 

 

In the httpGET function:

int response = InternetOpenUrlW(handler, strUrl,"",0, INTERNET_FLAG_NO_CACHE_WRITE |

             INTERNET_FLAG_PRAGMA_NOCACHE |

             INTERNET_FLAG_RELOAD); 

 

This is a good, and still working Library.

 

Has someone a solution how to increase or setup the timeout for the response ? 

 
Tell me how to update it in OnInit ()? atoms have to reload terminal
 
Still working, thank you for your great work
Reason: