Skip to content

Commit

Permalink
fixed invalid predefined mimetype for HP-PCL
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuth committed Apr 27, 2024
1 parent af3f2ff commit 720a95f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/main/kotlin/de/gmuth/ipp/attributes/DocumentFormat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class DocumentFormat(val mediaMimeType: String) : IppAttributeBuilder {

companion object {
// application

@JvmField
val OCTET_STREAM = DocumentFormat("application/octet-stream")

Expand All @@ -22,7 +23,13 @@ class DocumentFormat(val mediaMimeType: String) : IppAttributeBuilder {
@JvmField
val PDF = DocumentFormat("application/pdf")

// application/vnd

@JvmField
val HP_PCL = DocumentFormat("application/vnd.hp-PCL")

// image

@JvmField
val PWG_RASTER = DocumentFormat("image/pwg-raster")

Expand All @@ -35,9 +42,6 @@ class DocumentFormat(val mediaMimeType: String) : IppAttributeBuilder {
@JvmField
val PNG = DocumentFormat("image/png")

// vnd
@JvmField
val HP_PCL = DocumentFormat("vnd.hp-PCL")
}

override fun buildIppAttribute(printerAttributes: IppAttributesGroup) =
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/de/gmuth/ipp/attributes/Marker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Marker(
BLACK("#000000"),
YELLOW("#FFFF00"),
MAGENTA("#FF00FF"),
TRI_COLOR("#00FFFF#FF00FF#FFFF00"), // Cyan, Magenta, Yellow
CYAN_MAGENTA_YELLOW("#00FFFF#FF00FF#FFFF00"),
UNKNOWN("#?");

companion object {
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/de/gmuth/ipp/client/IppClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ open class IppClient(val config: IppConfig = IppConfig()) : IppExchange {
private fun HttpURLConnection.validateHttpResponse(
request: IppRequest,
contentStream: InputStream?,
cause: Exception? = null
exception: Exception? = null
) = when {
responseCode == 401 && request.operationGroup.containsKey("requesting-user-name") -> with(request) {
"User \"$requestingUserName\" is not authorized for operation $operation on $printerOrJobUri"
Expand All @@ -169,8 +169,8 @@ open class IppClient(val config: IppConfig = IppConfig()) : IppExchange {
responseCode == 426 -> "HTTP status $responseCode, $responseMessage, Try ipps://${request.printerOrJobUri.host}"
responseCode != 200 -> "HTTP request failed: $responseCode, $responseMessage"
contentType != null && !contentType.startsWith(APPLICATION_IPP) -> "Invalid Content-Type: $contentType"
cause != null -> cause.message
else -> null
exception != null -> exception.message
else -> null // no issues found
}?.let {
throw IppExchangeException(
request,
Expand All @@ -179,7 +179,7 @@ open class IppClient(val config: IppConfig = IppConfig()) : IppExchange {
httpHeaderFields = headerFields,
httpStream = contentStream,
message = it,
cause = cause
cause = exception
)
}

Expand Down

0 comments on commit 720a95f

Please sign in to comment.