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

Method getChankedHttpBody

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

Source from the content-addressed store, hash-verified

667 }
668
669 private static byte[] getChankedHttpBody(byte[] input_data) throws Exception {
670 // TODO 改行コードの対応
671 byte[] search_word = new String("\r\n").getBytes();
672 int index = 0;
673 int start_index = 0;
674 byte[] body = new byte[0];
675 while ((index = Utils.indexOf(input_data, start_index, input_data.length, search_word)) >= 0) {
676
677 try {
678
679 byte[] chank_header = ArrayUtils.subarray(input_data, start_index, index);
680 String chank_length_str = new String(chank_header, "UTF-8").replaceAll("^0+([^0].*)$", "$1");
681 int chank_length = Integer.parseInt(chank_length_str.trim(), 16);
682 if (chank_length == 0) {
683
684 return body;
685 }
686 byte[] chank = ArrayUtils.subarray(input_data, index + search_word.length,
687 index + search_word.length + chank_length);
688 body = ArrayUtils.addAll(body, chank);
689 start_index = index + search_word.length * 2 + chank_length;
690 } catch (Exception e) {
691
692 return null;
693 }
694 }
695 return null;
696 }
697
698 public InetSocketAddress getServerAddr() throws Exception {
699 return new InetSocketAddress(PrivateDNSClient.getByName(proxyHost), proxyPort);

Callers 1

parseHttpDelimiterMethod · 0.95

Calls 3

indexOfMethod · 0.95
getBytesMethod · 0.65
addAllMethod · 0.45

Tested by

no test coverage detected