Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. MW3 Modding Releases & Resources
  3. [Release] plutonium-http

[Release] plutonium-http

Scheduled Pinned Locked Moved MW3 Modding Releases & Resources
4 Posts 2 Posters 736 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ryano_undefined Offline
    ryano_undefined Offline
    ryano_
    wrote on last edited by ryano_
    #1

    Visit this project on Github: https://github.com/ryanocf/plutonium-http


    plutonium-http

    Making it possible to do basic http GET, POST, PUT & DELETE requests within ChaiScript.
    This plugin was mainly built for Plutonium MW3.


    Download

    Download the latest release and put the plutonium-http.dll in your servers plugin folder.


    Usage

    ❗ OpenSSL is currently not supported.
    Every function returns the same Vector scheme:

    0: version // String
    1: error // String
    2: status // Int
    3: reason // String
    4: body // String
    5: headers // Map
    
    /*
     * Params
     * url: String
     * route: String
     * headers: Map
     *
     * return: Vector
     */
    http_get("http://example.com", "/route", ["header": "value"]);
    
    /*
     * Params
     * url: String
     * route: String
     * body: String
     * headers: Map
     * content_type: String
     *
     * return: Vector
     */
    http_post("http://example.com", "/route", "body", ["header": "value"], "text/plain");
    http_post("http://example.com", "/route", "param=body&format=string", ["header": "value"], "application/x-www-form-urlencoded");
    
    /*
     * Params
     * url: String
     * route: String
     * body: String
     * headers: Map
     * content_type: String
     *
     * return: Vector
     */
    http_put("http://example.com", "/route", "body", ["header": "value"], "text/plain");
    http_put("http://example.com", "/route", "param=body&format=string", ["header": "value"], "application/x-www-form-urlencoded");
    
    /*
     * Params
     * url: String
     * route: String
     * body: String
     * headers: Map
     * content_type: String
     *
     * return: Vector
     */
    http_delete("http://example.com", "/route", "body", ["header": "value"], "text/plain");
    http_delete("http://example.com", "/route", "param=body&format=string", ["header": "value"], "application/x-www-form-urlencoded");
    

    Errors

    std::array<std::string, 13> error_list = {
        "Success",
        "Unknown",
        "Connection",
        "BindIPAddress",
        "Read",
        "Write",
        "ExceedRedirectCount",
        "Canceled",
        "SSLConnection",
        "SSLLoadingCerts",
        "SSLServerVerification",
        "UnsupportedMultipartBoundaryChars",
        "Compression"
    };
    

    Any questions or problems?
    Feel free to open an issue or visit this project on Plutonium.

    Credits

    https://github.com/yhirose/cpp-httplib
    https://github.com/ChaiScript/ChaiScript
    https://github.com/xensik/plutoscript

    1 Reply Last reply
    6
    • xensikundefined Offline
      xensikundefined Offline
      xensik
      wrote on last edited by
      #2

      The idea is cool, but you should make an asynchronous implementation.

      You are blocking the entire game thread with the http calls. this way is not very usable. Its specified in the cpp-httplib README that is a blocking library.

      ryano_undefined 1 Reply Last reply
      3
      • ryano_undefined Offline
        ryano_undefined Offline
        ryano_
        replied to xensik on last edited by
        #3

        xensik
        Thanks for the feedback.
        Yeah, I knew that tho I wanted to use an easy to port library (c++ -> chai).

        I haven't put that much thoughts into it tbh. but I will look into options on making the functions like tasks/threads.
        I don't have that high hopes bc. plugins are getting loaded/injected into the running server process sooo.. yeah I probably have to switch the library.

        For now, the best use case would be to do requests at the plugin's initialization and don't mess with it too much while players are on the server.

        xensikundefined 1 Reply Last reply
        0
        • xensikundefined Offline
          xensikundefined Offline
          xensik
          replied to ryano_ on last edited by
          #4

          ryano_
          you don't need to switch the library, but need a layer in between.

          you can make something like:

          • create 2 queues (requests and responses) with data and a chai callback

          • create a worker thread that wakes up when requests not empty, process them and store the result in responses queue.

          • create a hook at server frame, if responses not empty, call the chai callback with the response data.

          and the chai functions ('http_get '...) just store the data and callback in requests queue.

          1 Reply Last reply
          2

          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Donate