| 130 | } |
| 131 | |
| 132 | public HttpHeader(byte[] rawHttp) { |
| 133 | newLineSymbol = lookUpNewLineSymbol(rawHttp); |
| 134 | String newLineStr = newLineSymbol; |
| 135 | // パケットの先頭に改行が含まれているパターンがあるので回避 |
| 136 | if (Utils.indexOf(rawHttp, 0, newLineSymbol.length(), newLineSymbol.getBytes()) >= 0) { |
| 137 | |
| 138 | rawHttp = ArrayUtils.subarray(rawHttp, newLineSymbol.length(), rawHttp.length); |
| 139 | } |
| 140 | byte[] headerDelim = (newLineStr + newLineStr).getBytes(StandardCharsets.UTF_8); |
| 141 | int headerPos = Utils.indexOf(rawHttp, 0, rawHttp.length, headerDelim); |
| 142 | if (headerPos < 0) { |
| 143 | |
| 144 | headerPos = rawHttp.length; |
| 145 | } |
| 146 | String header = toUTF8(ArrayUtils.subarray(rawHttp, 0, headerPos)); |
| 147 | List<String> lines = Arrays.asList(header.split(newLineStr)); |
| 148 | statusLine = lines.get(0); |
| 149 | fields = lines.subList(1, lines.size()).stream().map(HeaderField::new).collect(Collectors.toList()); |
| 150 | } |
| 151 | |
| 152 | public String getStatusline() { |
| 153 | return statusLine; |