apache / apache/arrow-rs-object-store

Impossible to access `PutPayload` variant of `HTTPRequestBody` from custom `HttpConnector`

Open
#558 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
322
Forks
212
Avg merge
5d 2h
Merged PRs (30d)
10

Description

**Describe the bug**

When trying to implement a custom [`HttpConnector`](https://docs.rs/object_store/latest/object_store/client/trait.HttpConnector.html), one needs to implement [`HttpService`](https://docs.rs/object_store/latest/object_store/client/trait.HttpService.html). That service needs to operate on [`HttpRequest`](https://docs.rs/object_store/latest/object_store/client/type.HttpRequest.html), whose type of body is [`HttpRequestBody`](https://docs.rs/object_store/latest/object_store/client/struct.HttpRequestBody.html).

The implementation of `HttpRequestBody` is an enum with either a single or multiple buffers:

https://github.com/apache/arrow-rs-object-store/blob/12ef9bc22c56228b25f3b56a78879e9a45a07fc4/src/client/http/body.rs#L111-L112

But the public API of `HttpRequestBody` presents no way to access the `PutPayload` variant. There's an [`as_bytes`](https://docs.rs/object_store/latest/object_store/client/struct.HttpRequestBody.html#method.as_bytes) public method, but that returns `None` for `Inner::PutPayload`.

**To Reproduce**

(maybe this is a feature request instead of a bug report?)

**Expected behavior**

Should be able to access all internal variants through the public API.

**Additional context**

I'm [prototyping](https://github.com/developmentseed/obstore/pull/596) integrating the [`HttpConnector`](https://docs.rs/object_store/latest/object_store/client/trait.HttpConnector.html) into [`obstore`](https://github.com/developmentseed/obstore) — Python bindings to `object_store` — so that someone can define an arbitrary Python-based HTTP client to make the requests initiated by `object_store`.

Contributor guide

Open the contributing guide

Research direction

Start in src/client/http/body.rs around HttpRequestBody and its as_bytes method, then read the HttpConnector and HttpService entry points linked in the issue. Determine how the PutPayload variant should be exposed through the public API without breaking existing callers. Done means a custom HttpService can access every HttpRequestBody variant, with the relevant API behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.