moa icon indicating copy to clipboard operation
moa copied to clipboard

Adding Custom Headers to download request (Bearer {{access_token}}) for example

Open pierre-wehbe opened this issue 5 years ago • 1 comments

Would be great to customize headers of all requests for images that are behind a secure endpoint

pierre-wehbe avatar Feb 02 '21 22:02 pierre-wehbe

@pierre-wehbe that's a great idea, a pull request is always welcome.

We can add headers to MoaSettings and use it like this in an app:

Moa.settings.httpAdditionalHeaders = ["key": "value"]

which can then be added to URLSessionConfiguration.httpAdditionalHeaders in MoaHttpSession. However httpAdditionalHeaders does not accept all headers:

An NSURLSession object is designed to handle various aspects of the HTTP protocol for you. As a result, you should not modify the following headers: Authorization, Connection, Host, Proxy-Authenticate, Proxy-Authorization, WWW-Authenticate

so, if you use those we need a different approach.

evgenyneu avatar Feb 06 '21 00:02 evgenyneu