-
Notifications
You must be signed in to change notification settings - Fork 31
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
Rfc2045 decode #171
Rfc2045 decode #171
Conversation
I think this should be made configurable, maybe it is better to see first how this is going to be addressed in ocaml-base64 |
What would you think about allowing the caller to provide a |
As it stands it's not possible to use ocaml-rpc to interact with a server written in Python (using the xmlrpc library) that returns a base64-encoded value. |
I understand the reason behind the PR. As per the solution, I think it would be fine to provide an optional |
OK. I agree with you that some kind of parameterization is necesary to handle all the different cases (no line breaks, line breaks every 76 characters with |
Thanks for the contribution |
This commit allows callers of |
I've updated my proof of concept to use the proposed interface. |
src/lib/xmlrpc.mli
Outdated
@@ -22,40 +22,58 @@ val a_of_response | |||
|
|||
exception Parse_error of string * string * Xmlm.input | |||
|
|||
(* The parsing functions make it possible to specify the routine used to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(* The parsing functions make it possible to specify the routine used to | |
(** The parsing functions make it possible to specify the routine used to |
Let’s have this in the documentation
src/lib/xmlrpc.ml
Outdated
let make_enum = make (fun data -> Enum data) | ||
let make_dict = make (fun data -> Dict data) | ||
|
||
(* General parser functions *) | ||
let rec of_xml ?callback accu input = | ||
try value (map_tags (basic_types ?callback accu)) input with | ||
let rec of_xml ?callback ?base64_decode accu input = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let rec of_xml ?callback ?base64_decode accu input = | |
let rec of_xml ?callback ?base64_decoder accu input = |
I am bikeshedding here, but I would usebase64_decoder
as parameter name
Thanks. I like this. I think it makes sense to leave it only on the xmlrpc module right now. I would copy your little implementation of the base 64 decoder and maybe add a comment in the Readme or the documentation showing it and why it can be useful when communicating with python. But I can do that myself before releasing, after this is merged. thanks a lot for the contributions |
Thanks for your suggestions and maintainership! I think the final result we arrived at is reasonable and makes the library more useful. |
Thanks a lot for your patience and help! |
I will prepare a new release by the end of the week |
…c, rpc and ppx_deriving_rpc (8.1.2) CHANGES: * Add the `noargs` constructor for declaring interfaces that do not take any parameters. (tbrk mirage/ocaml-rpc#170) * Allow Xmlrpc callers to override the base64 decoding function. (tbrk mirage/ocaml-rpc#171)
Some XML-RPC servers break Base64 encoded data into lines of 76 characters long (see, e.g., the Python xmlrpc library). In these cases the
Base64.decode_exn
function raises an exceptionInvalid_argument "Malformed input"
.I propose, in this pull request, to decode using the
Base64_rfc2045
module which handles newlines. This module also decodes base64 strings without line breaks (in "dangerous" mode) and thus supports existing behavior.