Skip to content

Commit bdc78e2

Browse files
committed
added support for ipp scheme
1 parent 27cb503 commit bdc78e2

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

Diff for: README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ containing the Printer Simulator.
2121
### Usage
2222

2323
The tool takes two arguments: *printer-uri* and *file-name*.
24-
The url scheme `ipp://` is not supported - use `http://` instead.
2524
If you don't know the printer uri try `ippfind`.
2625

27-
java -jar printjob.jar http://colorjet:631/ipp/printer A4-blank.pdf
26+
java -jar printjob.jar ipp://colorjet:631/ipp/printer A4-blank.pdf
2827

29-
send ipp request to http://colorjet:631/ipp/printer
28+
send ipp request to ipp://colorjet:631/ipp/printer
3029
ipp version 1.1
3130
ipp response status: 0000
3231
group 01
@@ -42,7 +41,7 @@ If you don't know the printer uri try `ippfind`.
4241
The equivalent kotlin code is:
4342

4443
printJobStreamingVersion(
45-
URI.create("http://colorjet:631/ipp/printer"),
44+
URI.create("ipp://colorjet:631/ipp/printer"),
4645
FileInputStream(File("A4-blank.pdf"))
4746
)
4847

@@ -59,13 +58,13 @@ If required by your printer, you can set the document format programmatically by
5958

6059
If you use an unsupported `printer-uri` you will get a response similar to this one:
6160

62-
send ipp request to http://localhost:8632/ipp/norona
61+
send ipp request to ipp://localhost:8632/ipp/norona
6362
ipp version 1.1
6463
ipp status 0400
6564
group 01
6665
attributes-charset (47) = utf-8
6766
attributes-natural-language (48) = en
68-
status-message (41) = Bad printer-uri "http://localhost:8632/ipp/norona".
67+
status-message (41) = Bad printer-uri "ipp://localhost:8632/ipp/norona".
6968
group 03
7069

7170
You can use `ippfind` or `dns-sd -Z _ipp._tcp` (look at the rp value) to discover your printer's uri.

Diff for: build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tasks.withType<ShadowJar>() {
2222
archiveBaseName.set("printjob")
2323
archiveClassifier.set("")
2424
manifest {
25-
attributes(mapOf("Main-Class" to "ipp.PrintJobKt"))
25+
attributes(mapOf("Main-Class" to "ipp.PrintJobStreamingVersionKt"))
2626
}
2727
}
2828

Diff for: demo/go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
java -jar printjob.jar http://localhost:8632/printers/laser A4-blank.pdf
1+
java -jar printjob.jar ipp://localhost:8632/printers/laser A4-blank.pdf

Diff for: demo/printjob.jar

5.93 KB
Binary file not shown.

Diff for: src/main/kotlin/ipp/printJobByteArrayVersion.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ fun printJobByteArrayVersion(uri: URI, documentInputStream: InputStream) {
4343

4444
// exchange ipp messages via http
4545
println("send ipp request to $uri")
46-
val ippResponse = with(uri.toURL().openConnection() as HttpURLConnection) {
46+
val httpScheme = uri.scheme.replace("ipp", "http")
47+
val httpUri = URI.create("${httpScheme}:${uri.schemeSpecificPart}")
48+
val ippResponse = with(httpUri.toURL().openConnection() as HttpURLConnection) {
4749
val ippContentType = "application/ipp"
4850
setConnectTimeout(3000)
4951
setDoOutput(true)

Diff for: src/main/kotlin/ipp/printJobStreamingVersion.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ fun printJobStreamingVersion(uri: URI, documentInputStream: InputStream) {
2323
val ippContentType = "application/ipp"
2424

2525
println("send ipp request to $uri")
26-
val httpURLConnection = uri.toURL().openConnection() as HttpURLConnection
26+
val httpScheme = uri.scheme.replace("ipp", "http")
27+
val httpUri = URI.create("${httpScheme}:${uri.schemeSpecificPart}")
28+
val httpURLConnection = httpUri.toURL().openConnection() as HttpURLConnection
2729
with(httpURLConnection) {
2830
setConnectTimeout(3000)
2931
setDoOutput(true)

Diff for: src/main/kotlin/ipp/printJobWithStatusOnly.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ fun main(args: Array<String>) {
1919

2020
fun printJobWithStatusOnly(uri: URI, documentInputStream: InputStream) {
2121
val charset = Charsets.UTF_8
22-
with(uri.toURL().openConnection() as HttpURLConnection) {
22+
val httpScheme = uri.scheme.replace("ipp", "http")
23+
val httpUri = URI.create("${httpScheme}:${uri.schemeSpecificPart}")
24+
with(httpUri.toURL().openConnection() as HttpURLConnection) {
2325
setDoOutput(true)
2426
setRequestProperty("Content-Type", "application/ipp")
2527
// encode ipp request 'Print-Job operation'

0 commit comments

Comments
 (0)