private boolean parseDisposition(Buf src, BufRange dispoA, BufRange dispoB, BufRange name, BufRange filename) { if (BytesUtil.startsWith(src.bytes(), dispoA, NAME_EQ, false)) { name.assign(dispoA); name.strip(NAME_EQ.length, 0); BytesUtil.trim(src.bytes(), name); name.strip(1, 1); if (BytesUtil.startsWith(src.bytes(), dispoB, FILENAME_EQ, false)) { filename.assign(dispoB); filename.strip(FILENAME_EQ.length, 0); BytesUtil.trim(src.bytes(), filename); filename.strip(1, 1); } else { filename.reset(); } return true; } return 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; } }
private void checkCharset(Buf src, BufRange contType, BufRange contEnc, BufRange charset, BufRange contentType) { if (contentType != null) { BytesUtil.split(src.bytes(), contentType, SEMI_COL, contType, contEnc, true); if (BytesUtil.startsWith(src.bytes(), contEnc, CHARSET_EQ, false)) { charset.assign(contEnc); charset.strip(CHARSET_EQ.length, 0); BytesUtil.trim(src.bytes(), charset); if (!BytesUtil.matches(src.bytes(), charset, _UTF_8, false) && !BytesUtil.matches(src.bytes(), charset, _ISO_8859_1, false)) { Log.warn("Tipically the UTF-8 and ISO-8859-1 charsets are expected, but received different!", "charset", src.get(charset)); } } } }
private boolean parseDisposition(Buf src, BufRange dispoA, BufRange dispoB, BufRange name, BufRange filename) { if (BytesUtil.startsWith(src.bytes(), dispoA, NAME_EQ, false)) { name.assign(dispoA); name.strip(NAME_EQ.length, 0); BytesUtil.trim(src.bytes(), name); name.strip(1, 1); if (BytesUtil.startsWith(src.bytes(), dispoB, FILENAME_EQ, false)) { filename.assign(dispoB); filename.strip(FILENAME_EQ.length, 0); BytesUtil.trim(src.bytes(), filename); filename.strip(1, 1); } else { filename.reset(); } return true; } return 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; } }
private void checkCharset(Buf src, BufRange contType, BufRange contEnc, BufRange charset, BufRange contentType) { if (contentType != null) { BytesUtil.split(src.bytes(), contentType, SEMI_COL, contType, contEnc, true); if (BytesUtil.startsWith(src.bytes(), contEnc, CHARSET_EQ, false)) { charset.assign(contEnc); charset.strip(CHARSET_EQ.length, 0); BytesUtil.trim(src.bytes(), charset); if (!BytesUtil.matches(src.bytes(), charset, _UTF_8, false) && !BytesUtil.matches(src.bytes(), charset, _ISO_8859_1, false)) { Log.warn("Tipically the UTF-8 and ISO-8859-1 charsets are expected, but received different!", "charset", src.get(charset)); } } } }