/** * Convert a media type expressed as String into a {@link MediaType}. * * @param type A media type to parse. * @return An immutable {@link MediaType}. * @throws Err.BadMediaType For bad media types. */ public static MediaType valueOf(final String type) throws Err.BadMediaType { return parse(type).get(0); }
public RequestImpl(final Injector injector, final NativeRequest req, final String contextPath, final int port, final Route route, final Charset charset, final List<Locale> locales, final Map<Object, Object> scope, final Map<String, Object> locals, final long timestamp) { this.injector = injector; this.req = req; this.route = route; this.scope = scope; this.locals = locals; this.contextPath = contextPath; Optional<String> accept = req.header("Accept"); this.accept = accept.isPresent() ? MediaType.parse(accept.get()) : MediaType.ALL; this.lang = req.header("Accept-Language"); this.locales = locales; this.port = port; Optional<String> type = req.header("Content-Type"); this.type = type.isPresent() ? MediaType.valueOf(type.get()) : MediaType.all; String cs = this.type.params().get("charset"); this.charset = cs != null ? Charset.forName(cs) : charset; this.files = new ArrayList<>(); this.timestamp = timestamp; }
/** * Convert a media type expressed as String into a {@link MediaType}. * * @param type A media type to parse. * @return An immutable {@link MediaType}. * @throws Err.BadMediaType For bad media types. */ public static MediaType valueOf(final String type) throws Err.BadMediaType { return parse(type).get(0); }
public RequestImpl(final Injector injector, final NativeRequest req, final String contextPath, final int port, final Route route, final Charset charset, final List<Locale> locales, final Map<Object, Object> scope, final Map<String, Object> locals, final long timestamp) { this.injector = injector; this.req = req; this.route = route; this.scope = scope; this.locals = locals; this.contextPath = contextPath; Optional<String> accept = req.header("Accept"); this.accept = accept.isPresent() ? MediaType.parse(accept.get()) : MediaType.ALL; this.lang = req.header("Accept-Language"); this.locales = locales; this.port = port; Optional<String> type = req.header("Content-Type"); this.type = type.isPresent() ? MediaType.valueOf(type.get()) : MediaType.all; String cs = this.type.params().get("charset"); this.charset = cs != null ? Charset.forName(cs) : charset; this.files = new ArrayList<>(); this.timestamp = timestamp; }