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

XMLRPC boolean encoding #8

Closed
frln opened this Issue Dec 17, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@frln
Copy link

frln commented Dec 17, 2018

The client library will encode the boolean like <boolean> true </boolean> but the spec give <boolean> 1 </boolean> as an example. Should an XMLRPC server support both encoding?

@frln

This comment has been minimized.

Copy link

frln commented Dec 18, 2018

I need to test this but I think that the standard xmlrpc library of python will only accept 1 and 0 for boolean
https://github.com/python/cpython/blob/3.7/Lib/xmlrpc/client.py#L722

@scripting

This comment has been minimized.

Copy link
Owner

scripting commented Dec 18, 2018

For servers

Your server should handle any reasonable representation of a value. My server understands numbers or literals for booleans.

This follows half of Postel's Robustness Principle -- be liberal in what you accept.

For clients

At this stage, almost 20 years since the protocol was first deployed, you should start with the spec, and if you're not sure how to proceed, look at the examples in the spec and do what they do. Because that's likely what the people who came before did. Certainly all servers support the spec and the examples.

If it's still not clear, I'd look at the Python implementation as you're doing, also PHP or Java and do what they do. Servers would be certain to have tested with those three big implementations.

I have just published a JavaScript implementation (it's in this repo), and I checked, it generates the literal "true" for true and "false" for false.

But it's very new, and I don't know of anyone who has deployed with it, so I could change what it does.

@frln

This comment has been minimized.

Copy link

frln commented Dec 20, 2018

My first message was unclear, I'm actually trying to use the javascript client implementation to interact with the external api of Odoo, an ERP that apparently use the python library for managing XMLRPC request. The server threw at me an internal error that was fixed by changing the encoding from true/false to 1/0.

After some research, it seems that only PHP handle both true and 1. This Apache Java library documentation only mention 0 and 1 for boolean. And as stated above it seems that the python library only accept 0 and 1 without throwing an error.

@scripting

This comment has been minimized.

Copy link
Owner

scripting commented Dec 20, 2018

I figured it was something like that. :-)

@scripting scripting closed this Dec 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment