public HttpCookie(String name, String value) { super(name, value); setPath("/"); } }
public void addFormFile(final HttpFile file) { files.put(file.getParameterName(), file); }
components = path.getComponents(); ValidationResult result = new ValidationResult(); method.setValidationResult(result); for (int i = 0; i < params.length; i++) { boolean valid = param.getValidator().isValid(o); args[i] = RequiredParam.class.isAssignableFrom(param.getParameterType()) ? new RequiredParam<>(o, valid) : o; result.put(param.getName() + "_valid", valid); if (!valid) { result.invalid(); result.put(param.getName(), param.getValidator().getValidationMessage(param)); result.put(param.getName() + "_valid", true); args[i] = o;
/** * Because some custom fields depend on headers not set on construction this method * must be invoked after Netty populates the headers. * * @param ctx */ public void init(ChannelHandlerContext ctx) { String contentTypeStr = headers().get(HttpHeaders.Names.CONTENT_TYPE); this.contentType = MediaType.valueOf(contentTypeStr); String accept = headers().get(HttpHeaders.Names.ACCEPT); acceptedMediaTypes = MediaType.valueOf(accept); String cookiesStr = headers().get(HttpHeaders.Names.COOKIE); if (cookiesStr != null) { Set<Cookie> cookie = CookieDecoder.decode(cookiesStr); for (Cookie c : cookie) { cookies.put(c.getName(), new HttpCookie(c)); } } QueryStringDecoder decoderQuery = new QueryStringDecoder(getUri()); queryParams.putAll(decoderQuery.parameters()); if (config.isEnableSessions()) { initSession(ctx); } }
/** * Sets a cookie with path as "/" * * @param name * @param value */ public void setCookie(final String name, final String value) { HttpCookie cookie = new HttpCookie(name, value); cookie.setPath("/"); newCookies.put(name, cookie); }
protected Object extractQueryParam(MethodParam param, HttpRequest request) { //query string param can be a list or string, if neither set to null if (List.class.isAssignableFrom(param.getParameterType())) { return request.getQueryParams().get(param.getName()); } else if (String.class.isAssignableFrom(param.getParameterType())) { return request.getQueryParams().getFirst(param.getName()); } else { if (ReflectionUtil.isNumeric(param.getParameterType())) { //if param is a number then try to handle with NumberType.parseType return extractNumberParam(param, request.getQueryParams().getFirst(param.getName())); } else { return null; } } }
public HttpCookie getCookie(String name) { return cookies.get(name); }
public int getSize() { return size(); } }
public int getSize() { return size(); } }
public int getSize() { return size(); } }
public int getSize() { return size(); } }
public void addFormField(final String name, final Object value) { form.put(name, value); }
/** * Gets the first value of the query string parameter with the given name * * @param name the name of the query string parameter to get * @return the value of the parameter or null if it doesn't exist */ public String getFirst(String name) { List<String> vals = get(name); if (vals == null) { return null; } return vals.get(0); }
public void setCookie(final HttpCookie cookie) { newCookies.put(cookie.getName(), cookie); }
protected Object extractCookieParam(MethodParam param, HttpRequest request) { HttpCookie cookie = request.getCookie(param.getName()); if (cookie == null) { return null; } if (String.class.isAssignableFrom(param.getParameterType())) { return cookie.getValue(); } else if (HttpCookie.class.isAssignableFrom(param.getParameterType())) { return cookie; } else if (ReflectionUtil.isNumeric(param.getParameterType())) { //if param is a number then try to handle with NumberType.parseType return extractNumberParam(param, cookie.getValue()); } else { return null; } }
protected Object extractFormParam(MethodParam param, HttpRequest request) { Object obj = request.getFormParam().get(param.getName()); if (obj != null && param.getParameterType().isAssignableFrom(obj.getClass())) { return obj; } else { if (ReflectionUtil.isNumeric(param.getParameterType())) { //if param is a number then try to handle with NumberType.parseType return extractNumberParam(param, (String) request.getFormParam().get(param.getName())); } else { return null; } } }
/** * Sets a cookie with path as "/" * * @param name * @param value */ public void setCookie(final String name, final String value) { HttpCookie cookie = new HttpCookie(name, value); cookie.setPath("/"); setCookie(cookie); }