-
Notifications
You must be signed in to change notification settings - Fork 12
Allow multipart requests #259
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
base: master
Are you sure you want to change the base?
Conversation
Should we raise if someone attempts to binary insert or stream with multipart: true? |
👋 Thank you! I'll make sure to review it this week. My first thought is that if multipart form works, we should maybe just default to it :) |
That sounds great, but it does come at the cost of a larger request since the multipart body includes a bunch of boundaries and extra content. Not sure how impactful that would be but I believe we might benefit from making the behaviour configurable in some way, maybe through the config instead of parameters. If need be, I can take a deeper look into adapting the inserts and streams into multipart reqs too. |
👋 @hawkyre Sorry for the delay! Some preliminary notes:
|
Re config option, right now I'm leaning towards making it the default
|
@ruslandoga Let's do it with your custom multipart impl, it looks great. Did you manage to move the settings into the multipart in your version as well? It seems like that's the only thing pending. I agree on only parsing select statements into the multipart for now and making it the default, those are the only ones causing any problems. |
@ruslandoga Settings seem to be working great, I added your custom implementation to this PR with some refactoring to make things cleaner. Give it a look! |
Hi, @ruslandoga. I would love to see this merged 😉 |
Sorry for the delay! I'm vacationing this week and will revisit this next Monday. I think we still need to at least add settings support. This Ecto+Ch test fails with
when using this PR's branch: defp deps do
[
{:ch, github: "hawkyre/ch", branch: "send-params-in-multipart-form"},
# ... probably because right now the settings are going into the query string params (I haven't checked the new implementation, but something like this was the problem in #259 (comment)). |
Thanks for your answer @ruslandoga. Then, it's a good idea to revisit it from Monday on. |
I've looked into this a bit more. Sending the settings as parameters while the multipart body contains the query works, but I want to see if it's possible to also encode the settings in the body. |
Doing this in the multipart request pipeline also seems to work but it feels much cleaner to pass them as parameters |> then(
&Enum.reduce(settings, &1, fn {key, value}, acc ->
add_multipart_part(acc, to_string(key), to_string(value), enc_boundary)
end)
) |
Hm, you are right. Settings do get read from the query string while the multipart body contains the query. # returns `async_insert Bool 1`
curl -X POST \
-F 'query=show settings like \'async_insert\'' \
'http://localhost:8123/?async_insert=1' But not for this particular case. # works (old way)
curl -X POST \
-d 'create table low1(i8 LowCardinality(Int8)) order by tuple()' \
'http://localhost:8123/?allow_suspicious_low_cardinality_types=1'
# fails
curl -X POST \
-F 'query=create table low2(i8 LowCardinality(Int8)) order by tuple()' \
'http://localhost:8123/?allow_suspicious_low_cardinality_types=1'
# also fails (surprise)
# https://github.com/ClickHouse/ClickHouse/issues/85847
curl -X POST \
-F 'query=create table low2(i8 LowCardinality(Int8)) order by tuple()' \
-F 'allow_suspicious_low_cardinality_types=1' \
'http://localhost:8123/' Maybe we can limit multipart forms only to SELECT queries. Or queries with |
The issue gets even weirder with select queries. This doesn't work (it returns 5 rows): curl -X POST \
-F 'query=SELECT number, toString(number) FROM system.numbers LIMIT 5' \
-F 'max_result_rows=3' \
'http://localhost:8123/' But this does (query fails): curl -X POST \
-F 'query=SELECT number, toString(number) FROM system.numbers LIMIT 5' \
'http://localhost:8123/?max_result_rows=3' And even within the create query, the setting seems to be detected and parsed but is then ignored, because this fails saying the setting doesn't exist: curl -X POST \
-F 'query=create table low2(i8 LowCardinality(Int8)) order by tuple()' \
'http://localhost:8123/?allow_suspicious_low_cardinality_type=1' When passed through multiform it is just straight up ignored: # Same error as before, not a missing setting error
curl -X POST \
-F 'query=create table low2(i8 LowCardinality(Int8)) order by tuple()' \
-F 'allow_suspicious_low_cardinality_type=1' \
'http://localhost:8123/' |
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* fix internal type ordering in Variant * cleanup * link pr
@ruslandoga hey, it seems they fixed this 5 days ago: ClickHouse/ClickHouse#85570 But I'm running the tests in local with the Should we address this somehow? |
As commented in #258, this is another alternative to not send parameters through the URL that should also work. It's based on the form example in https://clickhouse.com/docs/interfaces/http. I've only allowed multipart requests if the body is a binary and the option multipart_request is set to true for inserts and selects, The others don't need to be sent as multipart requests since all the resources are already in the body