Nugine / s3s

S3 Service Adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose all headers / query parameters in S3Request

St4NNi opened this issue · comments

Hi and thanks again for your great work!

While exploring your library further we stumbled about another issue. For our use-case we need access to additional custom request headers and query parameters. Currently they are not exposed in the S3Request struct. Would it be ok to add another field that contains the header values and query parameters ? Currently this exposes only the Option<Credentials> and http::Extensions no other parameter from the original request. While it might be possible to hijack x-amz-meta or x-amz-tagging for this, it would make these features unusable in the future.

These might be filtered for custom values only, or in a first iteration only contain the full HeaderMap and/or Option<OrderedQs> from S3Extensions . Implementing this should not be a great deal, if you like i could give it a try.

Thanks!

Would it be ok to add another field that contains the header values and query parameters ?

It's reasonable. I think it is ok.

Implementing this should not be a great deal, if you like i could give it a try.

The related code is here. build_s3_request may consume anything from the http request.
You can prepare a PR and I'll review it soon.

fn build_s3_request<T>(input: T, req: &mut Request) -> S3Request<T> {
let credentials = req.s3ext.credentials.take();
let extensions = mem::take(&mut req.extensions);
S3Request {
input,
credentials,
extensions,
}
}

OrderedQs is now an internal structure. I'm not sure whether it is ok to expose such detail.
We may forward Uri and HeaderMap directly. Users can deserialize what they want from uri.query()

Sounds good, already working on it. I guess the raw URI would be even better if someone wants to do stuff with other URI parts.

Opened a PR (#27) unfortunately some tests were failing even before i started developing. But a small local test works, this should in theory not have any major side-effects.

Completed in #27