MCPcopy Create free account
hub / github.com/M66B/FairEmail / startCompression

Method startCompression

app/src/main/java/com/sun/mail/iap/Protocol.java:481–518  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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?

Callers 1

compressMethod · 0.80

Calls 8

simpleCommandMethod · 0.95
getIntPropertyMethod · 0.95
getInputStreamMethod · 0.65
getOutputStreamMethod · 0.65
setQuoteMethod · 0.45
isLoggableMethod · 0.45
logMethod · 0.45
setLevelMethod · 0.45

Tested by

no test coverage detected