Giter Site home page Giter Site logo

th0masl / webrequest2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from singafx/webrequest2

0.0 0.0 0.0 88 KB

A more powerful, drop-in replacement for the Metatrader 5 Webrequest() method

License: GNU General Public License v3.0

MQL5 100.00%

webrequest2's Introduction

webrequest2

A more powerful, drop-in replacement for the Metatrader 5 Webrequest() method. Based on wininet.dll

Highlights

  • Interface is fully compatible with the original WebRequest()
  • Use non standard Ports
  • Allow self signed ssl certs

Interface

int  WebRequest2(
   const string      method,                // HTTP method
   const string      url,                   // URL
   const string      headers,               // headers 
   int               timeout,               // timeout
   char              &data[],               // the array of the HTTP message body
   char              &result[],             // an array containing server response data
   string            &result_headers,       // headers of server response
   const int         port=NULL,             // Define custom port
   const bool        allowInsecure=false,   // Allow self signed certs
   const bool        useSSL=NULL            // Use SSL encrypted connection
   );

Return value HTTP server response code or -1 for an error.

Remarks

If allowInsecure is set to true the following flags are set:

SECURITY_FLAG_IGNORE_UNKNOWN_CA
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
SECURITY_FLAG_IGNORE_CERT_CN_INVALID
SECURITY_FLAG_IGNORE_REVOCATION

Please note that these Settings make SSL nearly useless. Therefore this flag should never be used in a environment where security matters! For reference check out: https://docs.microsoft.com/en-us/windows/desktop/winhttp/option-flags

The import "kernel32.dll" is used to retrieve the error messages.

Usage

  1. Clone repo and copy the contents of Libraries folder into the corresponding folder of your MetaTrader installation.
  2. Allow DLLs in your Terminal
  3. Import Library:
#include <..\Libraries\WebRequest2\WebRequest2.mq5>

Test the library

You can use the script Scripts/TestWebRequest2.mq5 as an example of how you can detect your Public IP by doing an HTTP/HTTPS request using this WebRequest library.

  1. Build the script Scripts/TestWebRequest2.mq5 using MetaEditor
  2. Copy the file TestWebRequest2.ex5 that has been built to the Scripts folder in your MetaTrader5 profile folder
  3. Open MetaTrader5 on a random chart
  4. Allow DLLs in your Terminal
  5. Load the script TestWebRequest2.ex5 from the Scripts folder
  6. In the Terminal journal, verify that your Public IP address has been detected correctly

Disclaimer

You use this software at your own risk! PR's welcome :)

webrequest2's People

Contributors

sirtoobii avatar th0masl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.