-
Notifications
You must be signed in to change notification settings - Fork 56
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
Customize query encoding scheme #80
base: main
Are you sure you want to change the base?
Conversation
Uri.t can now be created with an optional `query_scheme` parameter that controls the encoding of the query string. If it's omitted then the encoding defaults to the uri's own scheme. An implementation is given for query encoding according to amazon's standards to be used when writing clients for AWS.
Thanks for taking the initiative on this. I would like to find a solution that didn't require exceptions or schemes-which-aren't-schemes. In particular, it would be nice to override encoding of particular components without mentioning the rest. I don't particularly like special-casing the query component here. This would create a new type of value, an encoding, of which each scheme has at least a default. It could just be a record with fields for each component. What do you think? Also, we still support old OCaml versions so we can't use |
You're right about the exception bit but I'm not quite sure how would records help us with easier overriding of particular components. Isn't it already easy enough to override the way you describe: let my_scheme = function
| `Override_this -> ...
| x -> scheme_were_overriding x As for the exception I can just remove it and leave it to default to http for everything else. I think I understand what you're saying. Instead of a One thing that I think we can improve is to expose these different encodings via some type rather than a string. Of course this still doesn't let the user create her own encodings but it's fine for now. |
Rather than setting a `query_scheme`, a user may choose an `encoding`. If an `encoding` isn't chosen then it will be picked from `scheme` instead.
@dsheets OK I've modified the interface to be a bit closer to what I think you want. The next step IMO would be to create an abstract type for an encoding and just expose a few of the default values for it (aws, http, etc.). This would let us be pretty flexible with the implementation under the hood. |
@dsheets Friendly bump I'd be happy to work on this. |
Ok. Sorry for the delay. I will take a look at this soon. I have been traveling and am now quite crunched and jetlagged. |
No problem, take your time. Sorry for the eagerness. |
Could you create a type to encapsulate the percent-encoded set? I believe it is a property of the serialization of the URI only and not inherent to the identifier (but perhaps it affects deserialization somehow?). |
Friendly bump. I also hit the problem with pct encoding: Amazon doesn't allow char '=' in query values and I don't see any workaround except patching uri.ml to make '=' unsafe in query values. |
@dsheets @rgrinberg |
@AngryLawyer If you're using the latest version of cohttp you can set the request path ("resource") as a string and encode it however you want. Is that not enough? |
I did not know that. I should probably read the API a bit deeper |
@rgrinberg How would you do that with |
my modest attempt at tackling #65