(byte[] input_data)
| 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(); |
no test coverage detected