Skip to content

Commit

Permalink
feat(commonMain/onboarding): implemented custom headers (resolved #62)
Browse files Browse the repository at this point in the history
  • Loading branch information
aimok04 committed Feb 1, 2025
1 parent a39cf0e commit 93f1939
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<string name="common_copied_to_clipboard">In die Zwischenablage kopiert!</string>
<string name="common_count">Anzahl</string>
<string name="common_create_argument">» %1$s « erstellen</string>
<string name="common_custom_headers">Benutzerdefinierte Kopfzeilen</string>
<string name="common_day_after_tomorrow">Übermorgen</string>
<string name="common_day_before_yesterday">Vorgestern</string>
<string name="common_delete_permanently">Entgültig löschen</string>
Expand All @@ -108,6 +109,7 @@
<string name="common_end_date">End-Datum</string>
<string name="common_error_report">Fehlerbericht</string>
<string name="common_favorites">Favoriten</string>
<string name="common_field">Feld</string>
<string name="common_import_recipe">Rezept importieren</string>
<string name="common_info">Information</string>
<string name="common_ingredients">Zutaten</string>
Expand Down Expand Up @@ -177,6 +179,7 @@
<string name="common_unsaved_changes">Ungespeicherte Änderungen</string>
<string name="common_unsaved_changes_description">Wenn du fortfährst, gehen deine Änderungen verloren. Möchtest deine Änderungen verwerfen?</string>
<string name="common_username">Nutzername</string>
<string name="common_value">Wert</string>
<string name="common_version">Version</string>
<string name="common_website">Webseite</string>
<string name="common_welcome">Willkommen</string>
Expand Down
3 changes: 3 additions & 0 deletions composeApp/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<string name="common_copied_to_clipboard">Copied to your clipboard!</string>
<string name="common_count">Count</string>
<string name="common_create_argument">Create » %1$s «</string>
<string name="common_custom_headers">Custom headers</string>
<string name="common_day_after_tomorrow">Day after tomorrow</string>
<string name="common_day_before_yesterday">Day before yesterday</string>
<string name="common_delete_permanently">Delete permanently</string>
Expand All @@ -108,6 +109,7 @@
<string name="common_end_date">End date</string>
<string name="common_error_report">Error report</string>
<string name="common_favorites">Favorites</string>
<string name="common_field">Field</string>
<string name="common_import_recipe">Import recipe</string>
<string name="common_info">Information</string>
<string name="common_ingredients">Ingredients</string>
Expand Down Expand Up @@ -177,6 +179,7 @@
<string name="common_unsaved_changes">Unsaved changes</string>
<string name="common_unsaved_changes_description">If you continue, your changes will be lost. Do you want to discard your changes?</string>
<string name="common_username">Username</string>
<string name="common_value">Value</string>
<string name="common_version">Version</string>
<string name="common_website">Website</string>
<string name="common_welcome">Welcome</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.decodeFromJsonElement
import kotlinx.serialization.json.put

@Serializable
data class TandoorCredentialsCustomHeader(
var field: String,
var value: String
)

@Serializable
data class TandoorCredentialsToken(
val token: String,
Expand All @@ -35,7 +41,8 @@ data class TandoorCredentials(
var username: String = "",
val password: String = "",
var token: TandoorCredentialsToken? = null,
val cookie: String? = null
val cookie: String? = null,
val customHeaders: List<TandoorCredentialsCustomHeader> = listOf()
)

class TandoorClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class TandoorMedia(
} else {
set("Cookie", client.credentials.cookie ?: "")
}
}.apply {
client.credentials.customHeaders.forEach {
set(it.field, it.value)
}
}.build()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ suspend fun TandoorClient.reqAny(
set("Cookie", cookie)
}

credentials.customHeaders.forEach {
set(it.field, it.value)
}

set("Referer", credentials.instanceUrl)
}
if(data != null && contentType != null) {
Expand Down Expand Up @@ -162,6 +166,10 @@ suspend fun TandoorClient.reqMultipart(
set("Cookie", cookie)
}

credentials.customHeaders.forEach {
set(it.field, it.value)
}

set("Referer", credentials.instanceUrl)
}

Expand Down
Loading

0 comments on commit 93f1939

Please sign in to comment.