Raised This Month: $12 Target: $400
 3% 

REST in Pawn 1.3 - HTTP client for JSON REST APIs (Updated 2021/08/22)


Post New Thread Reply   
 
Thread Tools Display Modes
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 12-28-2019 , 06:00   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2019/12/28)
Reply With Quote #61

New release:
  • Switched to cURL multi interface with libuv for better performance
  • Added HTTP/2 support
  • Added ability to get response headers
  • Added JSONObject.HasKey native (thanks Rachnus)
  • Fixed memory leaks when a handle cannot be created
  • Fixed percent signs breaking JSON file paths
  • Return false instead of throwing an error if the key was not found in JSONObject.GetString
  • Updated cURL, Jansson and mbedTLS libraries
Download
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
BlacKisEverywhere
Junior Member
Join Date: Feb 2020
Old 03-06-2020 , 12:31   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2019/12/28)
Reply With Quote #62

What is curl "-u" representation
BlacKisEverywhere is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 03-06-2020 , 13:27   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2019/12/28)
Reply With Quote #63

Setting the Authorization header should work.

https://developer.mozilla.org/en-US/.../Authorization
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
BlacKisEverywhere
Junior Member
Join Date: Feb 2020
Old 03-06-2020 , 14:10   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2019/12/28)
Reply With Quote #64

Quote:
Setting the Authorization header should work.

https://developer.mozilla.org/en-US/.../Authorization


I think this type of authorization can't be set in header.
I tried to set authorization basic as header but this isn't working.
BlacKisEverywhere is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 03-06-2020 , 14:28   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2019/12/28)
Reply With Quote #65

So you base64-encoded "username:password" and appended the result after "Basic ", as explained on the page I linked?

Edit: seems to work.

PHP Code:
public void OnPluginStart()
{
    
HTTPClient client = new HTTPClient("https://jigsaw.w3.org/HTTP");
    
client.SetHeader("Authorization""Basic Z3Vlc3Q6Z3Vlc3Q=");
    
client.Get("Basic"OnHTTPResponse);
}

public 
void OnHTTPResponse(HTTPResponse responseany value)
{
    
PrintToServer("[Basic] %d"response.Status);

This returns a 200 response. If you comment out client.SetHeader() it returns a 401 response.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.

Last edited by DJ Tsunami; 03-06-2020 at 14:45.
DJ Tsunami is offline
BlacKisEverywhere
Junior Member
Join Date: Feb 2020
Old 03-06-2020 , 14:42   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2019/12/28)
Reply With Quote #66

After encode keys auth works correctly. Thanks for help and sorry for waste time
BlacKisEverywhere is offline
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 03-06-2020 , 15:02   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2019/12/28)
Reply With Quote #67

Awesome.
Could you make the Amxx version for CS 1.6?
milutinke is offline
Send a message via Skype™ to milutinke
CrazyHackGUT
AlliedModders Donor
Join Date: Feb 2016
Location: Izhevsk, Russia
Old 03-10-2020 , 07:22   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2019/12/28)
Reply With Quote #68

For AMXX you might can use gRIP (GoldSrc REST in Pawn). https://github.com/In-line/grip
__________________
My english is very bad. I am live in Russia. Learning english language - very hard task for me...
CrazyHackGUT is offline
Send a message via ICQ to CrazyHackGUT Send a message via Skype™ to CrazyHackGUT
mrtn
Junior Member
Join Date: May 2020
Old 05-18-2020 , 14:39   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2020/03/24)
Reply With Quote #69

Hi DJ Tsunami

Firstly many thanks for making this extension. It is fantastic!

Back in 2017 you mentioned that JSONObject iteration was not possible. I am wondering if this is still the case?

Here is an example of what I'm trying to do:

PHP Code:
{
    
"cvars":{
        
"mp_startmoney""800",
        
"mp_maxmoney""16000",
    }

I would like to iterate over the "cvars" property, extracting both the key and value for further processing.

How would I go about this? Is it possible to retrieve an array of keys from a JSONObject? Alternatively is it possible to extract the keys in a similar fashion to StringMaps, via StringMapSnapshot.GetKey(index)?

Thanks a lot

Last edited by mrtn; 05-18-2020 at 14:45.
mrtn is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 05-19-2020 , 03:52   Re: REST in Pawn 1.1 - HTTP client for JSON REST APIs (Updated 2020/03/24)
Reply With Quote #70

It's still not possible, but your use case is legitimate, so I'll look into it.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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