Start compression on the current connection. cmd is the command to issue to start compression. If the command succeeds, we begin compression. @param cmd the command to issue @exception IOException for I/O errors @exception ProtocolException for protocol failures
(String cmd)
| 479 | * @exception ProtocolException for protocol failures |
| 480 | */ |
| 481 | public synchronized void startCompression(String cmd) |
| 482 | throws IOException, ProtocolException { |
| 483 | // XXX - check whether compression is already enabled? |
| 484 | simpleCommand(cmd, null); |
| 485 | |
| 486 | // need to create our own Inflater and Deflater in order to set nowrap |
| 487 | Inflater inf = new Inflater(true); |
| 488 | traceInput = new TraceInputStream(new InflaterInputStream( |
| 489 | socket.getInputStream(), inf), traceLogger); |
| 490 | traceInput.setQuote(quote); |
| 491 | input = new ResponseInputStream(traceInput); |
| 492 | |
| 493 | // configure the Deflater |
| 494 | int level = PropUtil.getIntProperty(props, prefix + ".compress.level", |
| 495 | Deflater.DEFAULT_COMPRESSION); |
| 496 | int strategy = PropUtil.getIntProperty(props, |
| 497 | prefix + ".compress.strategy", |
| 498 | Deflater.DEFAULT_STRATEGY); |
| 499 | if (logger.isLoggable(Level.FINE)) |
| 500 | logger.log(Level.FINE, |
| 501 | "Creating Deflater with compression level {0} and strategy {1}", |
| 502 | new Object[] { level, strategy }); |
| 503 | Deflater def = new Deflater(Deflater.DEFAULT_COMPRESSION, true); |
| 504 | try { |
| 505 | def.setLevel(level); |
| 506 | } catch (IllegalArgumentException ex) { |
| 507 | logger.log(Level.FINE, "Ignoring bad compression level", ex); |
| 508 | } |
| 509 | try { |
| 510 | def.setStrategy(strategy); |
| 511 | } catch (IllegalArgumentException ex) { |
| 512 | logger.log(Level.FINE, "Ignoring bad compression strategy", ex); |
| 513 | } |
| 514 | traceOutput = new TraceOutputStream(new DeflaterOutputStream( |
| 515 | socket.getOutputStream(), def, true), traceLogger); |
| 516 | traceOutput.setQuote(quote); |
| 517 | output = new DataOutputStream(new BufferedOutputStream(traceOutput)); |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Is this connection using an SSL socket? |
no test coverage detected