From 445f9c6c923d408ec6c14e56a80d86bedb23e17e Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 28 Jun 2020 16:27:02 +0200 Subject: [PATCH] IPP: Accept replies without content-type My printer doesn't include a content-type in its replies. If a content-type is present, it should be the expected one. But if the printer doesn't specify it, we can try to parse the reply and see if it makes sense. Since the reauest has a content-type, it's reasonably safe to assume the reply will match the requested content type. Change-Id: I0fce7edd7cc40d2761b683d3e4c7b5316436e298 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2962 Reviewed-by: waddlesplash --- src/add-ons/print/transports/ipp/IppSetupDlg.cpp | 6 ++++-- src/add-ons/print/transports/ipp/IppTransport.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/add-ons/print/transports/ipp/IppSetupDlg.cpp b/src/add-ons/print/transports/ipp/IppSetupDlg.cpp index fb0046a9e9..5285fe3a96 100644 --- a/src/add-ons/print/transports/ipp/IppSetupDlg.cpp +++ b/src/add-ons/print/transports/ipp/IppSetupDlg.cpp @@ -121,10 +121,12 @@ bool IppSetupView::UpdateViewData() HTTP_RESPONSECODE response_code = conn.getResponseCode(); if (response_code == HTTP_OK) { const char *content_type = conn.getContentType(); - if (content_type && !strncasecmp(content_type, "application/ipp", 15)) { + if (content_type == NULL + || strncasecmp(content_type, "application/ipp", 15) == 0) { const IppContent *ipp_response = conn.getIppResponse(); if (ipp_response->good()) { - dir->WriteAttr(IPP_URL, B_STRING_TYPE, 0, url->Text(), strlen(url->Text()) + 1); + dir->WriteAttr(IPP_URL, B_STRING_TYPE, 0, url->Text(), + strlen(url->Text()) + 1); return true; } else { error_msg = ipp_response->getStatusMessage(); diff --git a/src/add-ons/print/transports/ipp/IppTransport.cpp b/src/add-ons/print/transports/ipp/IppTransport.cpp index 53494c29ad..a70638734a 100644 --- a/src/add-ons/print/transports/ipp/IppTransport.cpp +++ b/src/add-ons/print/transports/ipp/IppTransport.cpp @@ -107,7 +107,7 @@ IppTransport::~IppTransport() HTTP_RESPONSECODE response_code = conn.getResponseCode(); if (response_code == HTTP_OK) { const char *content_type = conn.getContentType(); - if (content_type && !strncasecmp(content_type, "application/ipp", 15)) { + if (content_type == NULL || strncasecmp(content_type, "application/ipp", 15) == 0) { const IppContent *ipp_response = conn.getIppResponse(); if (ipp_response->fail()) { __error = true;