HPInc / jipp

A Java-compatible implementation of IPP
MIT License
153 stars 42 forks source link

client-error-bad-request occurred when I try to get job attributes #107

Closed wwwqyhme closed 3 years ago

wwwqyhme commented 3 years ago

this is my print request :

Sending IppPacket(v=0x200, c=Print-Job(2), r=0x1) {
  operation-attributes {
    attributes-charset = utf-8,
    attributes-natural-language = en-us,
    printer-uri = ipp://192.168.1.127/ipp/print,
    requesting-user-name = "jprint" (name),
    document-format = application/PCLm },
  job-attributes { print-quality = normal(4), print-scaling = auto-fit } }

this is response

Received: IppPacket(v=0x200, c=successful-ok(0), r=0x1) {
  operation-attributes {
    attributes-charset = "utf-8" (charset),
    attributes-natural-language = "en-us" (naturalLanguage),
    printer-uri = ipp://192.168.1.127/ipp/print },
  job-attributes {
    job-id = 68,
    job-state = pending-held(4),
    job-state-reasons = job-hold-until-specified,
    job-uri = ipp://192.168.1.127/ipp/print/Job-68 } }

this is my get-job-attributes request:

IppPacket(v=0x200, c=Get-Job-Attributes(9), r=0x1) {
  operation-attributes {
    attributes-charset = utf-8,
    attributes-natural-language = en-us,
    job-uri = ipp://192.168.1.127/ipp/print/Job-68,
    requested-attributes = job-id } }

this is response:

IppPacket(v=0x200, c=client-error-bad-request(1024), r=0x1) {
  operation-attributes {
    attributes-charset = "utf-8" (charset),
    attributes-natural-language = "en-us" (naturalLanguage),
    printer-uri = ipp://192.168.1.127/ipp/print } }

my printer is HP Laser 108w

GladeDiviney commented 3 years ago

To what URL did you send the get-job-attributes request? As per https://tools.ietf.org/html/rfc8011#section-4.1.5 if you send this request to the printer-uri you must include a job-id.

(Closing because this question is beyond the scope of JIPP. This forum is for tracking JIPP issues.)

wifiprintguy commented 3 years ago

Although Clients SHOULD send printer-uri + job-id, the Printer is supposed to support either form described in RFC 8011 section 4.1.5. I'm guessing that switching the Get-Job-Attributes request to use printer-uri + job-id, as @GladeDiviney suggested, would result in a 'successful-ok' response.

GladeDiviney commented 3 years ago

https://tools.ietf.org/html/rfc8010#section-4 reads:

Each HTTP operation MUST use the POST method where the request-target is the object target of the operation

Which I take to mean a request targeting a job by its URI must be POSTed to that URI and not the Printer-URI.