Skip to content

Commit

Permalink
Renamed and restructured utilities in U class.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Jan 24, 2015
1 parent bca370f commit 5e9272a
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 117 deletions.
Expand Up @@ -91,7 +91,7 @@ public void str(TagContext ctx, Object content, int level, boolean inline, Objec
} }


indent(out, level, inline); indent(out, level, inline);
write(out, HTML.escape(U.text(content))); write(out, HTML.escape(U.readable(content)));
} }


protected void join(TagContext ctx, Collection<?> items, int level, boolean inline, Object extra, OutputStream out) { protected void join(TagContext ctx, Collection<?> items, int level, boolean inline, Object extra, OutputStream out) {
Expand Down
6 changes: 3 additions & 3 deletions rapidoid-http/src/main/java/org/rapidoid/http/HttpParser.java
Expand Up @@ -242,7 +242,7 @@ public void parseBody(Buf src, KeyValueRanges headers, Range body, KeyValueRange


src.get(multipartBoundary, helper.bytes, 2); src.get(multipartBoundary, helper.bytes, 2);


U.failIf(multipartBoundary.isEmpty(), "Invalid multi-part HTTP request!"); U.rteIf(multipartBoundary.isEmpty(), "Invalid multi-part HTTP request!");


parseMultiParts(src, body, data, files, multipartBoundary, helper); parseMultiParts(src, body, data, files, multipartBoundary, helper);
} else { } else {
Expand Down Expand Up @@ -334,7 +334,7 @@ private void parseMultiPart(Buf src, Range body, KeyValueRanges data, KeyValueRa
charset.strip(CHARSET_EQ.length, 0); charset.strip(CHARSET_EQ.length, 0);
BytesUtil.trim(src.bytes(), charset); BytesUtil.trim(src.bytes(), charset);


U.failIf(!BytesUtil.matches(src.bytes(), charset, _UTF_8, false), "Only the UTF-8 charset is supported!"); U.rteIf(!BytesUtil.matches(src.bytes(), charset, _UTF_8, false), "Only the UTF-8 charset is supported!");
} }
} }


Expand All @@ -345,7 +345,7 @@ private void parseMultiPart(Buf src, Range body, KeyValueRanges data, KeyValueRa
boolean validEncoding = BytesUtil.matches(src.bytes(), encoding, _7BIT, false) boolean validEncoding = BytesUtil.matches(src.bytes(), encoding, _7BIT, false)
|| BytesUtil.matches(src.bytes(), encoding, _8BIT, false) || BytesUtil.matches(src.bytes(), encoding, _8BIT, false)
|| BytesUtil.matches(src.bytes(), encoding, BINARY, false); || BytesUtil.matches(src.bytes(), encoding, BINARY, false);
U.failIf(!validEncoding, "Invalid Content-transfer-encoding header value!"); U.rteIf(!validEncoding, "Invalid Content-transfer-encoding header value!");
} }


if (filename.isEmpty()) { if (filename.isEmpty()) {
Expand Down
Expand Up @@ -62,8 +62,8 @@ protected void process(Channel ctx, HttpExchangeImpl x) {
parser.parse(x.input(), x.isGet, x.isKeepAlive, x.body, x.verb, x.uri, x.path, x.query, x.protocol, x.headers, parser.parse(x.input(), x.isGet, x.isKeepAlive, x.body, x.verb, x.uri, x.path, x.query, x.protocol, x.headers,
x.helper()); x.helper());


U.failIf(x.verb.isEmpty() || x.uri.isEmpty(), "Invalid HTTP request!"); U.rteIf(x.verb.isEmpty() || x.uri.isEmpty(), "Invalid HTTP request!");
U.failIf(x.isGet.value && !x.body.isEmpty(), "Body is NOT allowed in HTTP GET requests!"); U.rteIf(x.isGet.value && !x.body.isEmpty(), "Body is NOT allowed in HTTP GET requests!");


processRequest(x); processRequest(x);
} }
Expand Down
Expand Up @@ -140,7 +140,7 @@ protected void connectOP(SelectionKey key) throws IOException {
boolean ready; boolean ready;
try { try {
ready = socketChannel.finishConnect(); ready = socketChannel.finishConnect();
U.failIf(!ready, "Expected an established connection!"); U.rteIf(!ready, "Expected an established connection!");
connected.add(new RapidoidChannel(socketChannel, true)); connected.add(new RapidoidChannel(socketChannel, true));
} catch (ConnectException e) { } catch (ConnectException e) {
retryConnecting(target); retryConnecting(target);
Expand Down
Expand Up @@ -489,7 +489,7 @@ public static Var<Integer> localVar(String name, int defaultValue, int min, int
Var<Integer> var = sessionVar(name + ":" + Pages.viewId(x), defaultValue); Var<Integer> var = sessionVar(name + ":" + Pages.viewId(x), defaultValue);


// TODO put the constraints into the variable implementation // TODO put the constraints into the variable implementation
Integer pageN = U.limit(min, var.get(), max); Integer pageN = U.limited(min, var.get(), max);
var.set(pageN); var.set(pageN);


return var; return var;
Expand Down
Expand Up @@ -286,7 +286,7 @@ private static void setBeanProperties(Object instance, Map<String, String> param
} }


private static PojoDispatchException error(Throwable cause, String msg, Object... args) { private static PojoDispatchException error(Throwable cause, String msg, Object... args) {
return new PojoDispatchException(U.readable(msg, args), cause); return new PojoDispatchException(U.nice(msg, args), cause);
} }


private static PojoHandlerNotFoundException notFound() { private static PojoHandlerNotFoundException notFound() {
Expand Down

0 comments on commit 5e9272a

Please sign in to comment.