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
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 07-30-2017 , 11:28   Re: REST in Pawn - HTTP and JSON methodmaps
Reply With Quote #21

Good job
milutinke is offline
Send a message via Skype™ to milutinke
Dreizehnt
Junior Member
Join Date: Jan 2016
Location: Russian Federation
Old 08-14-2017 , 12:18   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #22

Hi, I have a problem:
HTML Code:
L 08/14/2017 - 19:07:16: [RIPEXT] HTTP request failed: Error reading ca cert file /etc/ssl/certs/ca-certificates.crt - mbedTLS: (-0x3E00) PK - Read/write of file failed
Technical support for hosting where I rent the game server states that the extension visits the directories above the server folder and should not do this. How to be? And what actions are performed in the folder: /etc/ssl/certs/
__________________
Dreizehnt is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-14-2017 , 13:00   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #23

It's because SSL_CERT_FILE environment variable is set to that path (which your user doesn't have permission to read). I guess you are trying to access a HTTPS endpoint? However, I don't know a fix. I'm sure you could Google that errors because it's a cURL error, it doesn't come from the extension.
klippy is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 08-31-2017 , 03:57   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #24

Version 1.0.3 now comes with the CA bundle in the configs/ripext folder, instead of it being hardcoded to /etc/ssl/certs/ca-certificates.crt. This fixes the issue above and also allows you to replace it with your own CA bundle if your API isn't trusted.
__________________
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; 08-31-2017 at 04:02.
DJ Tsunami is offline
rio_
Junior Member
Join Date: Feb 2017
Old 09-02-2017 , 02:11   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #25

Is there no way to see if a key exists in a JSONObject? Even GetString produces an exception if the key doesn't exist, and only returns false if the key is set but is null. I feel like that's a huge piece that's missing... It shouldn't be up to the API you're communicating with to insert a null value for every possible key it could return.

Last edited by rio_; 09-02-2017 at 20:37.
rio_ is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-02-2017 , 04:32   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #26

Hmm, that behaviour is wrong according to the SourceMod error model - errors should always be avoidable and thus always caused by programmer error (either due to misuse or missing checks).
__________________
asherkin is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 09-03-2017 , 05:42   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #27

Quote:
Originally Posted by rio_ View Post
It shoudn't be up to the API you're communicating with to insert a null value for every possible key it could return.
I agree, it shouldn't. You should know which fields are returned based on the API's documentation. And APIs should be versioned so that changes don't break existing calls.

Quote:
Originally Posted by asherkin View Post
errors should always be avoidable and thus always caused by programmer error (either due to misuse or missing checks).
I'm not sure what's considered "programmer error" in this case. If you pass an invalid index to an ADT array it throws an error, but if you pass an invalid key to an ADT trie it returns false. So the former is programmer error, but the latter is not?
__________________
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; 09-04-2017 at 10:59.
DJ Tsunami is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 09-04-2017 , 14:17   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #28

Quote:
Originally Posted by DJ Tsunami View Post
I'm not sure what's considered "programmer error" in this case. If you pass an invalid index to an ADT array it throws an error, but if you pass an invalid key to an ADT trie it returns false. So the former is programmer error, but the latter is not?
Given an arbitrary adt array it's possible to prevent going out of bounds with a Length check.

Given an arbitrary adt trie it's not possible to prevent a lookup to a non-existing key based on any check - thus the lookups need to be safe.

Even without that the lack of a "key existence check", most languages don't let you index to random parts of dynamic arrays (exception / undefined behavior), but most will let you attempt lookups to non-existent keys in maps.
__________________
splewis is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-04-2017 , 14:24   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #29

Quote:
Originally Posted by splewis View Post
Given an arbitrary adt array it's possible to prevent going out of bounds with a Length check.

Given an arbitrary adt trie it's not possible to prevent a lookup to a non-existing key based on any check - thus the lookups need to be safe.
This is exactly it.

(Yes, a KeyExists function and throwing on invalid keys would also be suitable for the error model, but you pay the hash and lookup penalty twice, so it is simpler in that case to do in one go.)
__________________
asherkin is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 09-05-2017 , 03:01   Re: REST in Pawn - Communicate with JSON REST APIs
Reply With Quote #30

https://sm.alliedmods.net/api/index....d=show&id=692&

The ADT_Array API doesn't support this behaviour either (see how with GetTrieValue the return is the state of the key, and the param is actually optional (well; should be)).

Anyways; yeah, in a bunch of plugins I do similar things with checking keys; this is definitely the more intuitive approach then erroring out if a single json key is missing (is this really the point of contention???).
KyleS 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 08:37.


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