shinyorg / shiny

.NET Framework for Backgrounding & Device Hardware Services (iOS, Android, & Catalyst)
https://shinylib.net
MIT License
1.43k stars 227 forks source link

[Feature Request]: Allow specifying user-agent header on NSURLSession Config #1411

Closed breenbob closed 6 months ago

breenbob commented 6 months ago

Summary

As per this link the NSURLSession automatically includes a default user agent in this format: $(CFBundleName)/$(CFBundleVersion) CFNetwork/808.3 Darwin/17.2.0

I believe this is cause of an issue currently blocking me from using Shiny.Net.Http in my iOS app, where all requests to download files from our AWS CDN fail with a 403 error. The URL passed in to the download task is correct, works in the browser and on Android.

According to that same link, next answer further down on the page, the NSURLSessionConfiguration allows you to specify user agent header like so: config.httpAdditionalHeaders = ["User-Agent": "myapp User-Agent"]

API Changes

Add a new nullable string property to AppleConfiguration for CustomUserAgent. Check if null or empty where AppleConfig values are mapped to NSURLConfiguration and set custom user agent string.

Intended Use Case

For scenario where backend server requires specific user agents to be used.

Code of Conduct

aritchie commented 6 months ago

There will be new configuration options in the next minor release