MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / gunzip

Method gunzip

src/main/java/core/packetproxy/http/Http.java:601–630  ·  view source on GitHub ↗
(byte[] input_data)

Source from the content-addressed store, hash-verified

599 }
600
601 private static byte[] gunzip(byte[] input_data) throws Exception {
602 if (input_data.length == 0) {
603
604 return input_data;
605 }
606 try {
607
608 ByteArrayInputStream in = new ByteArrayInputStream(input_data);
609 GZIPInputStream gzin = new GZIPInputStream(in);
610 return IOUtils.toByteArray(gzin);
611 } catch (Exception e) {
612
613 /* Streaming Responseサポートのため、中途半端なgzipを展開しないといけないケースが多々ある */
614 byte[] zipped = input_data;
615 InputStream in = new GZIPInputStream(new ByteArrayInputStream(zipped));
616 byte[] inflates = new byte[zipped.length * 10];
617 int inflatesLength = 0;
618 ByteArrayOutputStream unzipped = new ByteArrayOutputStream();
619 try {
620
621 while ((inflatesLength = in.read(inflates, 0, inflates.length)) > 0) {
622
623 unzipped.write(ArrayUtils.subarray(inflates, 0, inflatesLength));
624 }
625 } catch (Exception e1) {
626
627 }
628 return unzipped.toByteArray();
629 }
630 }
631
632 private static byte[] gzip(byte[] input_data) throws Exception {
633 ByteArrayOutputStream out = new ByteArrayOutputStream();

Callers 2

parseHttpDelimiterMethod · 0.95
getCookedBodyMethod · 0.95

Calls 3

writeMethod · 0.65
toByteArrayMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected