AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Module: Curl (https://forums.alliedmods.net/showthread.php?t=285656)

Levenus Supremus 07-27-2016 06:20

Module: Curl
 
UPDATE
Note the new module https://github.com/Next21Team/AmxxEasyHttp
It has new easy to use API! Without read/write callbacks, problems with certificates and does not require clearing resources.

Description:
AmxxCurl module is a wrapper over libcurl easy interface for amxmodx. Module performs curl's in non-blocking mode.

Download latest version here.

Few words about libcurl (from wiki page):
Quote:

libcurl is a free client-side URL transfer library, supporting FTP, FTPS, Gopher, HTTP, HTTPS, SCP, SFTP, TFTP, Telnet, DICT, the file URI scheme, LDAP, LDAPS, IMAP, POP3, SMTP and RTSP. The library supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, Kerberos, HTTP form-based upload, proxies, cookies, user-plus-password authentication, file transfer resume, and HTTP proxy tunneling.
So, this means that with this module you can send/check mails via IMAP, POP3 protocols; perform HTTPS requests (example); download/upload files over FTP (example). And it's only general capabilities. Here some examples written on C, but it almost that Pawn)

Natives:
All natives you can find in curl.inc, they have the same behaviour that C functions.

Except for some:
1)
Code:

native void:curl_easy_perform(const CURL:handle, const callbackComplite[], const data[] = {}, const data_len = 0)
The function starts curl perform, and upon completion of the transfer will be call callback callbackComplite. In third parameter you can specify an array of user data, wich will be transferred to callbackComplite, and fourth parameter is array length.

If user data set, callback should have the signature:
Code:

public compliteCallback(CURL:curl, CURLcode:code, data[])
else:
Code:

public compliteCallback(CURL:curl, CURLcode:code)
2)
Code:

native CURLcode:curl_easy_getinfo(const CURL:handle, const CURLINFO:info, any:...)
For string type of CURLINFO option, you must set fourth argument - string size:
Code:

new url[64]
curl_easy_getinfo(curl,CURLINFO_EFFECTIVE_URL, url, charsmax(url))

Important things
1) if you are using callback WRITEFUNCTION, always specify the option CURLOPT_BUFFERSIZE. Specify something about 512-1024, or risk getting a stack overflow error.
2) If you are would like to use READFUNCTION callback, set pragma dynamic in 16536 or more:
Code:

#pragma dynamic 16536
Author: Polarhigh (aka Levenus Supremus)
Source code: https://github.com/Polarhigh/AmxxCurl
Releases: https://github.com/Polarhigh/AmxxCurl/releases

PRoSToTeM@ 07-27-2016 12:17

Re: Module: Curl
 
For amxx module you need install meta plugin? It is so crutch.

Levenus Supremus 07-27-2016 12:27

Re: Module: Curl
 
openssl library is critically important library, such a solution allows to hot swap if in openssl current version vulnerability will found.

Shooting King 07-27-2016 16:05

Re: Module: Curl
 
Omg you made it first :( I though of adding it into ThreadedSockets :(

Also i don't think there is a need for it to be a MetaMod Plugin, even if its linked to Metamod or Amxmodx (which is in-turn linked to MM), the outcome would be the same.

PRoSToTeM@ 07-27-2016 16:46

Re: Module: Curl
 
Quote:

Originally Posted by Levenus Supremus (Post 2439986)
openssl library is critically important library, such a solution allows to hot swap if in openssl current version vulnerability will found.

Can't you integrate openssl library into your module?

Neeeeeeeeeel.- 07-27-2016 18:04

Re: Module: Curl
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2440046)
Can't you integrate openssl library into your module?

He has just stated WHY it is important (and critical) to have it separely...

PRoSToTeM@ 07-27-2016 18:49

Re: Module: Curl
 
Quote:

Originally Posted by Neeeeeeeeeel.- (Post 2440059)
He has just stated WHY it is important (and critical) to have it separely...

Missed out, thx.

Destro- 07-27-2016 21:41

Re: Module: Curl
 
ohh, good module :)

Levenus Supremus 07-28-2016 09:22

Re: Module: Curl
 
Quote:

Originally Posted by Shooting King (Post 2440039)
Omg you made it first :( I though of adding it into ThreadedSockets :(

Also i don't think there is a need for it to be a MetaMod Plugin, even if its linked to Metamod or Amxmodx (which is in-turn linked to MM), the outcome would be the same.

I'm not first too)
https://github.com/alldroll/curl_module

Ok, maybe you and PRoSToTeM@ rights, but i thought that it better and simpler.

Quote:

Originally Posted by PRoSToTeM@ (Post 2440046)
Can't you integrate openssl library into your module?

In future.

PartialCloning 08-04-2016 16:28

Re: Module: Curl
 
The natives should be documented with comments explaining how they work. I know they can be looked up, but an include file in itself should give you a general idea of how to work with the natives.


All times are GMT -4. The time now is 09:52.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.