Download MetaTrader 5

Discussion of article "Using WinInet in MQL5. Part 2: POST Requests and Files"

To add comments, please log in or register
Add our channel to friends and follow the news!
MetaQuotes Software Corp.
Moderator
181403
MetaQuotes Software Corp. 2011.06.08 14:43 

New article Using WinInet in MQL5. Part 2: POST Requests and Files is published:

In this article, we continue studying the principles of working with Internet using HTTP requests and exchange of information with server. It describes new functions of the CMqlNet class, methods of sending information from forms and sending of files using POST requests as well as authorization on websites under your login using Cookies.

Author: Alex Sergeev

investeo
4098
investeo 2011.06.09 09:43  

Hi Alex,

Good article - I have a request for 'Part 3': XML-RPC client communication (and server if possible).

Cheerz 

trad
168
trad 2011.07.30 18:41  

When executing the following statement, the system crashes, how this should be resolved? 

hConnect=InternetConnectW(hSession, aHost, aPort, aUser, aPass, aService, 0, 0);  

Error: Access violation read to 0x0000000000001F94 in '......ex5'

 

 

 

MundoForex
61
MundoForex 2011.09.09 04:56  

There is a little bug on line 161. That line should be:

else StringToCharArray(req.stData, data, 0, StringLen(req.stData));

that's because terminal 0 is copied to the array and HttpSendRequestW sends the terminal 0 (like an extra character) to the last post var value. For example if your data is:

var1=value1&var2=value2

You will get in your web page var1 associated to value1, and var2 associated to value2\0.

This is a great article. Thanks for sharing it.


Regards

fjccpm
117
fjccpm 2012.02.14 13:48  
after the last MT5 upgrade the wininet cant be used, ir generates an access violation error. Any suggestions to overcome this error? solutions? I've been trying without success.
MundoForex
61
MundoForex 2012.02.27 20:18  

Access violation error was solved but POST requests are not working now. Apparently the data in an uchar array is not correctly sent to the dll function.
fjccpm
117
fjccpm 2012.02.28 01:46  
mundoforex:

Access violation error was solved but POST requests are not working now. Apparently the data in an uchar array is not correctly sent to the dll function.
I'm still having access violation errors after some time.
MundoForex
61
MundoForex 2012.02.28 22:57  

Why nobody cares this problem??
fjccpm
117
fjccpm 2012.02.29 16:06  
mundoforex:

Why nobody cares this problem??
I'm with you... I'm desperately waiting for a solution but no one answers. I thought the last update was going to solve the problem as the admins told me, but after the update the never answered me again :(
Viktor Placek
581
Viktor Placek 2016.04.24 14:48  

I also had some Access Violation error with this object class. The problem was in using '0' as a NULL pointer in call of HttpOpenRequestW function. Try to replace the call

---   hRequest=HttpOpenRequestW(hConnect, req.stVerb, req.stObject, Vers, nill, 0, INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_RELOAD|INTERNET_FLAG_PRAGMA_NOCACHE, 0); 

with a call:

+++   hRequest=HttpOpenRequestW(hConnect, req.stVerb, req.stObject, Vers, NULL, NULL , INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_RELOAD|INTERNET_FLAG_PRAGMA_NOCACHE, 0); 


It is funny, that improper use of NULL pointer is even explicitly mentioned as a crash reason in MSDN documentation:

Failing to properly terminate the array with a NULL pointer will cause a crash.
HttpOpenRequest function (Windows)
  • msdn.microsoft.com
Creates an HTTP request handle. Syntax Parameters hConnect [in] lpszVerb [in] A pointer to a null-terminated string that contains the HTTP verb to use in the request. If this parameter is NULL, the function uses GET as the HTTP verb. lpszObjectName [in] A pointer to a null-terminated string that contains the name of the target object of the...
To add comments, please log in or register