private void consumeAndSkip(int toPos, BufRange range, int skip) { range.setInterval(_position, toPos); _position = toPos + skip; }
private boolean getKeepAliveValue(Bytes bytes, BufRange connHdr, RapidoidHelper helper) { assert bytes != null; assert connHdr != null; BufRange connVal = helper.ranges5.ranges[3]; connVal.setInterval(connHdr.start + CONNECTION.length, connHdr.limit()); BytesUtil.trim(bytes, connVal); return BytesUtil.matches(bytes, connVal, KEEP_ALIVE, false); }
public static boolean split(Bytes bytes, BufRange target, byte sep, BufRange before, BufRange after, boolean trimParts) { int pos = find(bytes, target.start, target.limit(), sep, true); if (pos >= 0) { before.setInterval(target.start, pos); after.setInterval(pos + 1, target.limit()); if (trimParts) { trim(bytes, before); trim(bytes, after); } return true; } else { before.assign(target); after.reset(); if (trimParts) { trim(bytes, before); } return false; } }
range.setInterval(start, absPos); position(absPos + 1); assert invariant(false); range.setInterval(start, absPos); position(absPos + 1); assert invariant(false); range.setInterval(start, absPos); position(absPos + 1); assert invariant(false);
range.setInterval(start, absPos); position(absPos); assert invariant(false); range.setInterval(start, absPos); position(absPos); assert invariant(false); range.setInterval(start, absPos); position(absPos); assert invariant(false);
private void parseBody(Buf buf, RapidoidHelper helper) { BufRanges headers = helper.headers; BufRange body = helper.body; BufRange clen = headers.getByPrefix(buf.bytes(), CONTENT_LENGTH, false); if (clen != null) { BufRange clenValue = helper.ranges5.ranges[helper.ranges5.ranges.length - 1]; clenValue.setInterval(clen.start + CONTENT_LENGTH.length, clen.limit()); BytesUtil.trim(buf.bytes(), clenValue); long len = buf.getN(clenValue); U.must(len >= 0 && len <= Integer.MAX_VALUE, "Invalid body size!"); buf.scanN((int) len, body); Log.debug("Request body complete", "range", body); } else { body.reset(); } }
private HttpContentType getContentType(Buf buf, KeyValueRanges headers, BufRange multipartBoundary) { BufRange contType = headers.get(buf, CONTENT_TYPE, false); if (contType != null) { if (BytesUtil.startsWith(buf.bytes(), contType, CT_FORM_URLENCODED, false)) { multipartBoundary.reset(); return HttpContentType.FORM_URLENCODED; } if (BytesUtil.startsWith(buf.bytes(), contType, CT_JSON, false)) { multipartBoundary.reset(); return HttpContentType.JSON; } if (BytesUtil.startsWith(buf.bytes(), contType, CT_MULTIPART_FORM_DATA_BOUNDARY1, false)) { multipartBoundary.setInterval(contType.start + CT_MULTIPART_FORM_DATA_BOUNDARY1.length, contType.limit()); return HttpContentType.MULTIPART; } if (BytesUtil.startsWith(buf.bytes(), contType, CT_MULTIPART_FORM_DATA_BOUNDARY2, false)) { multipartBoundary.setInterval(contType.start + CT_MULTIPART_FORM_DATA_BOUNDARY2.length, contType.limit()); return HttpContentType.MULTIPART; } if (BytesUtil.startsWith(buf.bytes(), contType, CT_MULTIPART_FORM_DATA, false)) { multipartBoundary.reset(); return HttpContentType.MULTIPART; } } multipartBoundary.reset(); return contType != null ? HttpContentType.OTHER : HttpContentType.NOT_FOUND; }
result.setInterval(fromPos, i - 1); } else { result.setInterval(fromPos, i);
result.setInterval(fromPos, i); int nextPos = i + 1; return matchedPrefix ? -nextPos : nextPos;
partBody.setInterval(bodyPos, to);
private void consumeAndSkip(int toPos, BufRange range, int skip) { range.setInterval(_position, toPos); _position = toPos + skip; }
private boolean getKeepAliveValue(Bytes bytes, BufRange connHdr, RapidoidHelper helper) { assert bytes != null; assert connHdr != null; BufRange connVal = helper.ranges5.ranges[3]; connVal.setInterval(connHdr.start + CONNECTION.length, connHdr.limit()); BytesUtil.trim(bytes, connVal); return BytesUtil.matches(bytes, connVal, KEEP_ALIVE, false); }
public static boolean split(Bytes bytes, BufRange target, byte sep, BufRange before, BufRange after, boolean trimParts) { int pos = find(bytes, target.start, target.limit(), sep, true); if (pos >= 0) { before.setInterval(target.start, pos); after.setInterval(pos + 1, target.limit()); if (trimParts) { trim(bytes, before); trim(bytes, after); } return true; } else { before.assign(target); after.reset(); if (trimParts) { trim(bytes, before); } return false; } }
range.setInterval(start, absPos); position(absPos + 1); assert invariant(false); range.setInterval(start, absPos); position(absPos + 1); assert invariant(false); range.setInterval(start, absPos); position(absPos + 1); assert invariant(false);
range.setInterval(start, absPos); position(absPos); assert invariant(false); range.setInterval(start, absPos); position(absPos); assert invariant(false); range.setInterval(start, absPos); position(absPos); assert invariant(false);
private void parseBody(Buf buf, RapidoidHelper helper) { BufRanges headers = helper.headers; BufRange body = helper.body; BufRange clen = headers.getByPrefix(buf.bytes(), CONTENT_LENGTH, false); if (clen != null) { BufRange clenValue = helper.ranges5.ranges[helper.ranges5.ranges.length - 1]; clenValue.setInterval(clen.start + CONTENT_LENGTH.length, clen.limit()); BytesUtil.trim(buf.bytes(), clenValue); long len = buf.getN(clenValue); U.must(len >= 0 && len <= Integer.MAX_VALUE, "Invalid body size!"); buf.scanN((int) len, body); Log.debug("Request body complete", "range", body); } else { body.reset(); } }
private HttpContentType getContentType(Buf buf, KeyValueRanges headers, BufRange multipartBoundary) { BufRange contType = headers.get(buf, CONTENT_TYPE, false); if (contType != null) { if (BytesUtil.startsWith(buf.bytes(), contType, CT_FORM_URLENCODED, false)) { multipartBoundary.reset(); return HttpContentType.FORM_URLENCODED; } if (BytesUtil.startsWith(buf.bytes(), contType, CT_JSON, false)) { multipartBoundary.reset(); return HttpContentType.JSON; } if (BytesUtil.startsWith(buf.bytes(), contType, CT_MULTIPART_FORM_DATA_BOUNDARY1, false)) { multipartBoundary.setInterval(contType.start + CT_MULTIPART_FORM_DATA_BOUNDARY1.length, contType.limit()); return HttpContentType.MULTIPART; } if (BytesUtil.startsWith(buf.bytes(), contType, CT_MULTIPART_FORM_DATA_BOUNDARY2, false)) { multipartBoundary.setInterval(contType.start + CT_MULTIPART_FORM_DATA_BOUNDARY2.length, contType.limit()); return HttpContentType.MULTIPART; } if (BytesUtil.startsWith(buf.bytes(), contType, CT_MULTIPART_FORM_DATA, false)) { multipartBoundary.reset(); return HttpContentType.MULTIPART; } } multipartBoundary.reset(); return contType != null ? HttpContentType.OTHER : HttpContentType.NOT_FOUND; }
result.setInterval(fromPos, i - 1); } else { result.setInterval(fromPos, i);
result.setInterval(fromPos, i); int nextPos = i + 1; return matchedPrefix ? -nextPos : nextPos;
partBody.setInterval(bodyPos, to);