|
1 | | -plutonium-http |
| 1 | +# <div align="center">plutonium-http</div> |
| 2 | + |
| 3 | +<div align="center"> |
| 4 | + <img src="https://img.shields.io/badge/License-MIT-important?style=flat-square" /> |
| 5 | + <img src="https://img.shields.io/badge/%E2%80%8E-C++-00599C?style=flat-square&logoWidth=20&logo=image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHZpZXdCb3g9IjAgMCAyNCAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48dGl0bGU+QysrIGljb248L3RpdGxlPjxwYXRoIGZpbGw9IndoaXRlIiBkPSJNMjIuMzkzIDZjLS4xNjctLjI5LS4zOTgtLjU0My0uNjUyLS42OUwxMi45MjUuMjJjLS41MDgtLjI5My0xLjMzOS0uMjkzLTEuODQ3IDBMMi4yNiA1LjMxYy0uNTA4LjI5My0uOTIzIDEuMDEzLS45MjMgMS42djEwLjE4YzAgLjI5NC4xMDQuNjIuMjcxLjkxLjE2Ny4yOS4zOTguNTQzLjY1Mi42ODlsOC44MTYgNS4wOTFjLjUwOC4yOTMgMS4zMzkuMjkzIDEuODQ3IDBsOC44MTYtNS4wOTFjLjI1NC0uMTQ2LjQ4NS0uMzk5LjY1Mi0uNjg5cy4yNzEtLjYxNi4yNzEtLjkxVjYuOTFjLjAwMi0uMjk0LS4xMDItLjYyLS4yNjktLjkxek0xMiAxOS4xMDljLTMuOTIgMC03LjEwOS0zLjE4OS03LjEwOS03LjEwOVM4LjA4IDQuODkxIDEyIDQuODkxYTcuMTMzIDcuMTMzIDAgMCAxIDYuMTU2IDMuNTUybC0zLjA3NiAxLjc4MUEzLjU2NyAzLjU2NyAwIDAgMCAxMiA4LjQ0NWMtMS45NiAwLTMuNTU0IDEuNTk1LTMuNTU0IDMuNTU1UzEwLjA0IDE1LjU1NSAxMiAxNS41NTVhMy41NyAzLjU3IDAgMCAwIDMuMDgtMS43NzhsMy4wNzcgMS43OEE3LjEzNSA3LjEzNSAwIDAgMSAxMiAxOS4xMDl6bTcuMTA5LTYuNzE0aC0uNzl2Ljc5aC0uNzl2LS43OWgtLjc5di0uNzloLjc5di0uNzloLjc5di43OWguNzl2Ljc5em0yLjk2MiAwaC0uNzl2Ljc5aC0uNzl2LS43OWgtLjc4OXYtLjc5aC43ODl2LS43OWguNzl2Ljc5aC43OXYuNzl6Ii8+PC9zdmc+" /> |
| 6 | + <br/><br/> |
| 7 | + Making it possible to do basic http GET, POST, PUT & DELETE requests within ChaiScript.<br/> |
| 8 | + This plugin was mainly built for <a href="https://plutonium.pw/">Plutonium MW3</a>. |
| 9 | +</div> |
| 10 | + |
| 11 | +___ |
| 12 | + |
| 13 | +## Download |
| 14 | + |
| 15 | +Download the [latest release](https://github.com/ryanocf/plutonium-http/releases) and put the <kbd>**plutonium-http.dll**</kbd> in your servers plugin folder. |
| 16 | + |
| 17 | +___ |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +:exclamation: **OpenSSL is currently not supported.**<br/> |
| 22 | +Every function returns the same Vector scheme: |
| 23 | + |
| 24 | +```c++ |
| 25 | +0: version |
| 26 | +1: error |
| 27 | +2: status |
| 28 | +3: reason |
| 29 | +4: body |
| 30 | +5: headers |
| 31 | +``` |
| 32 | + |
| 33 | +```c++ |
| 34 | +/* |
| 35 | + * Params |
| 36 | + * url: String |
| 37 | + * route: String |
| 38 | + * headers: Map |
| 39 | + * |
| 40 | + * return: Vector |
| 41 | + */ |
| 42 | +http_get("http://example.com", "/route", ["header": "value"]); |
| 43 | +``` |
| 44 | +
|
| 45 | +```c++ |
| 46 | +/* |
| 47 | + * Params |
| 48 | + * url: String |
| 49 | + * route: String |
| 50 | + * body: String |
| 51 | + * headers: Map |
| 52 | + * content_type: String |
| 53 | + * |
| 54 | + * return: Vector |
| 55 | + */ |
| 56 | +http_post("http://example.com", "/route", "body" ["header": "value"], "text/plain"); |
| 57 | +http_post("http://example.com", "/route", "param=body&format=string" ["header": "value"], "application/x-www-form-urlencoded"); |
| 58 | +``` |
| 59 | + |
| 60 | +```c++ |
| 61 | +/* |
| 62 | + * Params |
| 63 | + * url: String |
| 64 | + * route: String |
| 65 | + * body: String |
| 66 | + * headers: Map |
| 67 | + * content_type: String |
| 68 | + * |
| 69 | + * return: Vector |
| 70 | + */ |
| 71 | +http_put("http://example.com", "/route", "body" ["header": "value"], "text/plain"); |
| 72 | +http_put("http://example.com", "/route", "param=body&format=string" ["header": "value"], "application/x-www-form-urlencoded"); |
| 73 | +``` |
| 74 | +
|
| 75 | +```c++ |
| 76 | +/* |
| 77 | + * Params |
| 78 | + * url: String |
| 79 | + * route: String |
| 80 | + * body: String |
| 81 | + * headers: Map |
| 82 | + * content_type: String |
| 83 | + * |
| 84 | + * return: Vector |
| 85 | + */ |
| 86 | +http_delete("http://example.com", "/route", "body" ["header": "value"], "text/plain"); |
| 87 | +http_delete("http://example.com", "/route", "param=body&format=string" ["header": "value"], "application/x-www-form-urlencoded"); |
| 88 | +``` |
| 89 | + |
| 90 | +___ |
| 91 | + |
| 92 | +## Errors |
| 93 | + |
| 94 | +```c++ |
| 95 | +std::array<std::string, 13> error_list = { |
| 96 | + "Success", |
| 97 | + "Unknown", |
| 98 | + "Connection", |
| 99 | + "BindIPAddress", |
| 100 | + "Read", |
| 101 | + "Write", |
| 102 | + "ExceedRedirectCount", |
| 103 | + "Canceled", |
| 104 | + "SSLConnection", |
| 105 | + "SSLLoadingCerts", |
| 106 | + "SSLServerVerification", |
| 107 | + "UnsupportedMultipartBoundaryChars", |
| 108 | + "Compression" |
| 109 | +}; |
| 110 | +``` |
| 111 | + |
| 112 | +___ |
| 113 | + |
| 114 | +Any questions or problems?<br/> |
| 115 | +Feel free to open an [issue](https://github.com/ryanocf/plutonium-http/issues/new) or visit this project on [Plutonium](https://forum.plutonium.pw/). |
| 116 | + |
| 117 | +## Credits |
| 118 | + |
| 119 | +https://github.com/yhirose/cpp-httplib<br/> |
| 120 | +https://github.com/ChaiScript/ChaiScript<br/> |
| 121 | +https://github.com/xensik/plutoscript |
0 commit comments