Skip to content
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

feat:Support custom headers for iOS request #40

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import platform.Foundation.NSBundle
import platform.Foundation.NSData
import platform.Foundation.NSMutableURLRequest
import platform.Foundation.NSURL
import platform.Foundation.NSURLRequest
import platform.Foundation.create
import platform.Foundation.setValue
import platform.WebKit.WKWebView
import platform.darwin.NSObject
import platform.darwin.NSObjectMeta
Expand All @@ -34,11 +34,19 @@ class IOSWebView(private val wkWebView: WKWebView) : IWebView {
additionalHttpHeaders: Map<String, String>,
) {
KLogger.d { "Load url: $url" }
val request =
NSMutableURLRequest.requestWithURL(
URL = NSURL(string = url),
)
additionalHttpHeaders.all { (key, value) ->
request.setValue(
value = value,
forHTTPHeaderField = key,
)
true
}
wkWebView.loadRequest(
request =
NSURLRequest(
uRL = NSURL(string = url),
),
request = request,
)
}

Expand Down