From: mike Date: Thu, 31 Jan 2013 15:48:00 +0000 (+0000) Subject: Fix a missing state change bug in httpWrite2(). X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eadcd99cf39138f1446c14dbe4c1bffbc573e78a;p=thirdparty%2Fcups.git Fix a missing state change bug in httpWrite2(). Add a deflate compression test file. Add .pwg to the list of recognized extensions for PWG Raster. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10847 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/cups/http.c b/cups/http.c index c437a50ce6..e2d12c34be 100644 --- a/cups/http.c +++ b/cups/http.c @@ -976,8 +976,19 @@ httpFlushWrite(http_t *http) /* I - Connection to server */ if (http->data_encoding == HTTP_ENCODING_CHUNKED) bytes = http_write_chunk(http, http->wbuffer, http->wused); else + { bytes = http_write(http, http->wbuffer, http->wused); + if (bytes > 0 && http->data_encoding == HTTP_ENCODING_LENGTH) + { + http->data_remaining -= bytes; + + if (http->data_remaining <= 0) + { + } + } + } + http->wused = 0; DEBUG_printf(("1httpFlushWrite: Returning %d, errno=%d.", bytes, errno)); @@ -3677,6 +3688,11 @@ httpWrite2(http_t *http, /* I - Connection to server */ * data, go idle... */ +#ifdef HAVE_LIBZ + if (http->coding) + http_content_coding_finish(http); +#endif /* HAVE_LIBZ */ + if (http->wused) { if (httpFlushWrite(http) < 0) @@ -3700,17 +3716,12 @@ httpWrite2(http_t *http, /* I - Connection to server */ } if (http->state == HTTP_STATE_POST_RECV) - { -#ifdef HAVE_LIBZ - if (http->coding) - http_content_coding_finish(http); -#endif /* HAVE_LIBZ */ - http->state ++; + else + http->state = HTTP_STATE_WAITING; - DEBUG_printf(("2httpWrite2: Changed state to %s.", - http_states[http->state + 1])); - } + DEBUG_printf(("2httpWrite2: Changed state to %s.", + http_states[http->state + 1])); } DEBUG_printf(("1httpWrite2: Returning " CUPS_LLFMT ".", CUPS_LLCAST bytes)); diff --git a/test/Makefile b/test/Makefile index 8f592290ec..b9375d76ae 100644 --- a/test/Makefile +++ b/test/Makefile @@ -48,6 +48,7 @@ TESTFILES = \ ipp-2.2.test \ ipp-everywhere.test \ print-job.test \ + print-job-deflate.test \ print-job-gzip.test OBJS = \ ippserver.o \ diff --git a/test/ipp-everywhere.test b/test/ipp-everywhere.test index 5ba8a9df2b..4260cd815b 100644 --- a/test/ipp-everywhere.test +++ b/test/ipp-everywhere.test @@ -18,7 +18,7 @@ # # Do all of the IPP/1.1 and IPP/2.0 tests -#INCLUDE "ipp-2.0.test" +INCLUDE "ipp-2.0.test" # Test required printer description attribute support. diff --git a/test/ippserver.c b/test/ippserver.c index ba4df8b864..f182477184 100644 --- a/test/ippserver.c +++ b/test/ippserver.c @@ -3824,7 +3824,8 @@ process_http(_ipp_client_t *client) /* I - Client connection */ if (httpError(client->http) == EPIPE) fprintf(stderr, "%s Client closed connection.\n", client->hostname); else - fprintf(stderr, "%s Bad request line.\n", client->hostname); + fprintf(stderr, "%s Bad request line (%s).\n", client->hostname, + strerror(httpError(client->http))); return (0); } diff --git a/test/ipptool.c b/test/ipptool.c index 6dce764963..99f3b5236a 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -478,7 +478,9 @@ main(int argc, /* I - Number of command-line args */ else if (!_cups_strcasecmp(ext, ".ps") || !_cups_strcasecmp(ext, ".ps.gz")) set_variable(&vars, "filetype", "application/postscript"); - else if (!_cups_strcasecmp(ext, ".ras") || + else if (!_cups_strcasecmp(ext, ".pwg") || + !_cups_strcasecmp(ext, ".pwg.gz") || + !_cups_strcasecmp(ext, ".ras") || !_cups_strcasecmp(ext, ".ras.gz")) set_variable(&vars, "filetype", "image/pwg-raster"); else if (!_cups_strcasecmp(ext, ".txt") || diff --git a/test/print-job-deflate.test b/test/print-job-deflate.test new file mode 100644 index 0000000000..e54028d6d0 --- /dev/null +++ b/test/print-job-deflate.test @@ -0,0 +1,31 @@ +# Print a test page using print-job and compression=gzip +{ + # The name of the test... + NAME "Print file using Print-Job and compression=deflate" + + # The operation to use + OPERATION Print-Job + + # Attributes, starting in the operation group... + GROUP operation-attributes-tag + ATTR charset attributes-charset utf-8 + ATTR language attributes-natural-language en + ATTR uri printer-uri $uri + ATTR name requesting-user-name $user + ATTR mimeMediaType document-format $filetype + ATTR keyword compression deflate + + GROUP job-attributes-tag + ATTR integer copies 1 + + COMPRESSION deflate + FILE $filename + + # What statuses are OK? + STATUS successful-ok + STATUS successful-ok-ignored-or-substituted-attributes + + # What attributes do we expect? + EXPECT job-id + EXPECT job-uri +} diff --git a/tools/makeipptoolpkg b/tools/makeipptoolpkg index 1c2721a3c6..f6552a85f8 100755 --- a/tools/makeipptoolpkg +++ b/tools/makeipptoolpkg @@ -66,6 +66,7 @@ cp test/ipptool-static $pkgdir/ipptool cp test/onepage-*.pdf $pkgdir cp test/onepage-*.ps $pkgdir cp test/print-job.test $pkgdir +cp test/print-job-deflate.test $pkgdir cp test/print-job-gzip.test $pkgdir cp test/testfile.* $pkgdir