Skip to content

Commit

Permalink
status-message
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Oct 5, 2024
1 parent 9b9a1a1 commit 39ebb36
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/kotlin/de/gmuth/ipp/core/IppResponse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ package de.gmuth.ipp.core
* Copyright (c) 2020-2024 Gerhard Muth
*/

import de.gmuth.ipp.core.IppTag.Operation
import de.gmuth.ipp.core.IppTag.Unsupported
import de.gmuth.ipp.core.IppTag.*
import java.nio.charset.Charset
import java.util.logging.Level
import java.util.logging.Logger
Expand Down Expand Up @@ -39,9 +38,13 @@ class IppResponse : IppMessage {
version: String = "2.0",
requestId: Int = 1,
charset: Charset = Charsets.UTF_8,
naturalLanguage: String = "en"
naturalLanguage: String = "en",
statusMessage: IppString? = null,
) : super(version, requestId, charset, naturalLanguage) {
code = status.code
with(operationGroup) {
statusMessage?.let { attribute("status-message", TextWithLanguage, it) }
}
}

override fun log(logger: Logger, level: Level, prefix: String) {
Expand All @@ -51,6 +54,9 @@ class IppResponse : IppMessage {

override fun toString() = StringBuilder().apply {
append(status)
if (!status.isSuccessful() && operationGroup.containsKey("status-message")) {
append(", '$statusMessage'")
}

val statesAndReasons = attributesGroups
.flatMap { group -> group.values }
Expand Down

0 comments on commit 39ebb36

Please sign in to comment.