-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization for certain API Interfaces #5398
Comments
for case 2, should the modification be forward compatible? |
@yuekun0707 |
ok, thanks for your reply~ |
I can see there are both doGet() and doPost() methods in this HTTP API services. from my understanding, there are many common logic that can be used both in doGet() and doPost() methods. |
@xq-lu |
Keep in mind to keep compatibility. |
Will |
Of course.
Yes, it will be compatible with this content-type. |
Rationale
Currently, java-tron's HTTP interfaces support GET and POST requests. However, there are some inconsistencies in parameter validation and response between GET and POST calls for the same interface. Here are some examples:
case1: incorrect log level for invalid parameter
/wallet/getapprovedlist
When passing an invalid parameter like modifying
type_url
totype_url1
, the server logs an ERROR:case2: inconsistent naming convention for parameters
/wallet/getavailableunfreezecount
The GET and POST requests have inconsistent naming for the parameter
ownerAddress
(GET) vsowner_address
(POST).case3: GET parameter handling contradicts business logic
/wallet/getcanwithdrawunfreezeamount
For the
timestamp
parameter, the GET request throwsNumberFormatException
if missing while POST handles it as 0 by default, which aligns with business logic./wallet/getcandelegatedmaxsize
For the
type
parameter, GET request throwsNumberFormatException
if missing while POST handles it as 0 by default, which aligns with business logic./wallet/getblockbynum
For the
num
parameter, POST resolves it to 0 without passing it, and GET throws an error. To make it compatible, GET should be consistent with POST.Implementation
To summarize, 3 cases are listed where GET and POST have inconsistencies. The solutions are as follows:
case1:change log level for invalid parameter validation
case2:standardize naming conventions
case3:align GET handling with POST logic
The text was updated successfully, but these errors were encountered: